From nancy at ucar.edu Thu May 3 11:14:18 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Thu, 03 May 2012 11:14:18 -0600 Subject: [Dart-dev] [5712] DART/branches/development/assim_tools/assim_tools_mod.html: minor updates to include more links to the references Message-ID: Revision: 5712 Author: nancy Date: 2012-05-03 11:14:17 -0600 (Thu, 03 May 2012) Log Message: ----------- minor updates to include more links to the references section, remove quotes around 'parallel'. Modified Paths: -------------- DART/branches/development/assim_tools/assim_tools_mod.html -------------- next part -------------- Modified: DART/branches/development/assim_tools/assim_tools_mod.html =================================================================== --- DART/branches/development/assim_tools/assim_tools_mod.html 2012-04-26 19:38:05 UTC (rev 5711) +++ DART/branches/development/assim_tools/assim_tools_mod.html 2012-05-03 17:14:17 UTC (rev 5712) @@ -37,14 +37,16 @@

Overview

-This module provides subroutines that implement the 'parallel' versions +This module provides subroutines that implement the parallel versions of the sequential scalar filter algorithms. These include the standard -sequential filter as described in Anderson (2003) along with systematic +sequential filter as described in + Anderson 2001, 2003 along with systematic correction algorithms for both mean and spread. In addition, algorithms to do a variety of flavors of filters including the EAKF, ENKF, particle filter, and kernel filters are included. The parallel implementation that allows each observation to update all state variables that are close -to it at the same time is described in Anderson and Collins (2007). +to it at the same time is described in +Anderson and Collins, 2007.

@@ -53,17 +55,24 @@ Available observation space filter types include:

-Most users use type 1, the EAKF. +We recommend using type=1, the EAKF. +Note that although the algorithm +is expressed in a slightly different form, +the EAKF is identical to the +EnSRF (Ensemble Square Root Filter) +described by Whitaker and Hamill in 2002.

@@ -588,7 +597,7 @@ doi: 10.1175/1520-0493(2001)129<2884:AEAKFF>2.0.CO;2 -
+

  • Anderson, J. L., 2003: A Local Least Squares Framework for Ensemble Filtering. @@ -597,7 +606,7 @@ doi: 10.1175/1520-0493(2003)131<0634:ALLSFF>2.0.CO;2 -
    +

  • Anderson, J., Collins, N., 2007: Scalable Implementations of Ensemble Filter Algorithms for Data Assimilation. @@ -605,7 +614,7 @@ 24, 1452-1463.
    doi: 10.1175/JTECH2049.1 -
    +

  • Anderson, J. L., 2010: A Non-Gaussian Ensemble Filter Update for Data Assimilation. @@ -614,7 +623,7 @@ doi: 10.1175/2010MWR3253.1 -
    +

  • Anderson, J. L., 2011:, Localization and Sampling Error Correction From nancy at ucar.edu Tue May 8 14:27:20 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Tue, 08 May 2012 14:27:20 -0600 Subject: [Dart-dev] [5713] DART/branches/development/observations: Preliminary program to create three flux observations from the AmeriFlux Message-ID: Revision: 5713 Author: thoar Date: 2012-05-08 14:27:20 -0600 (Tue, 08 May 2012) Log Message: ----------- Preliminary program to create three flux observations from the AmeriFlux Level 4 data. The three observation types are: LE_f (Latent Heat Flux) TOWER_LATENT_HEAT_FLUX H_f (Sensible Heat Flux) TOWER_SENSIBLE_HEAT_FLUX NEE_or_fMDS (Net Ecosystem Production) TOWER_NETC_ECO_EXCHANGE It is possible, perhaps even desirable, to rewrite these to include more metadata. There are tower-site-specific attributes like land cover, land use, plant functional type available from the FLUXNET sites ... e.g. http://fluxnet.ornl.gov/site/886 This could then be used to inform the observation operator to only query the appropriate PFTs from a grid cell ... Added Paths: ----------- DART/branches/development/observations/Ameriflux/ DART/branches/development/observations/Ameriflux/level4_to_obs.f90 DART/branches/development/observations/Ameriflux/level4_to_obs.html DART/branches/development/observations/Ameriflux/level4_to_obs.nml DART/branches/development/observations/Ameriflux/shell_scripts/ DART/branches/development/observations/Ameriflux/work/ DART/branches/development/observations/Ameriflux/work/input.nml DART/branches/development/observations/Ameriflux/work/mkmf_level4_to_obs DART/branches/development/observations/Ameriflux/work/mkmf_obs_sequence_tool DART/branches/development/observations/Ameriflux/work/mkmf_preprocess DART/branches/development/observations/Ameriflux/work/path_names_level4_to_obs DART/branches/development/observations/Ameriflux/work/path_names_obs_sequence_tool DART/branches/development/observations/Ameriflux/work/path_names_preprocess DART/branches/development/observations/Ameriflux/work/quickbuild.csh -------------- next part -------------- Added: DART/branches/development/observations/Ameriflux/level4_to_obs.f90 =================================================================== --- DART/branches/development/observations/Ameriflux/level4_to_obs.f90 (rev 0) +++ DART/branches/development/observations/Ameriflux/level4_to_obs.f90 2012-05-08 20:27:20 UTC (rev 5713) @@ -0,0 +1,602 @@ +! DART software - Copyright 2004 - 2011 UCAR. This open source software is +! provided by UCAR, "as is", without charge, subject to all terms of use at +! http://www.image.ucar.edu/DAReS/DART/DART_download + +program level4_to_obs + +! +! $URL$ +! $Id$ +! $Revision$ +! $Date$ + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! +! level4_to_obs - a program that only needs minor customization to read +! in a text-based dataset - either white-space separated values or +! fixed-width column data. +! +! created 3 May 2012 Tim Hoar NCAR/IMAGe +! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +use types_mod, only : r8, MISSING_R8 + +use utilities_mod, only : initialize_utilities, finalize_utilities, & + register_module, error_handler, E_MSG, E_ERR, & + open_file, close_file, do_nml_file, do_nml_term, & + check_namelist_read, find_namelist_in_file + +use time_manager_mod, only : time_type, set_calendar_type, GREGORIAN, & + set_date, set_time, get_time, print_time, & + print_date, operator(-), operator(+) + +use location_mod, only : VERTISHEIGHT + +use obs_sequence_mod, only : obs_sequence_type, obs_type, read_obs_seq, & + static_init_obs_sequence, init_obs, write_obs_seq, & + init_obs_sequence, get_num_obs, & + set_copy_meta_data, set_qc_meta_data + +use obs_kind_mod, only : TOWER_SENSIBLE_HEAT_FLUX, & + TOWER_NETC_ECO_EXCHANGE, & + TOWER_LATENT_HEAT_FLUX + +implicit none + +!----------------------------------------------------------------------- +! version controlled file description for error handling, do not edit +!----------------------------------------------------------------------- + +character(len=128), parameter :: & + source = "$URL$", & + revision = "$Revision$", & + revdate = "$Date$" + +!----------------------------------------------------------------------- +! Namelist with default values +!----------------------------------------------------------------------- + +character(len=128) :: text_input_file = 'textdata.input' +character(len=128) :: obs_out_file = 'obs_seq.out' +integer :: year +real(r8) :: timezoneoffset +real(r8) :: latitude +real(r8) :: longitude +real(r8) :: elevation +real(r8) :: flux_height +real(r8) :: maxgoodqc = 3 +logical :: verbose = .false. + +namelist /level4_to_obs_nml/ text_input_file, obs_out_file, year, & + timezoneoffset, latitude, longitude, elevation, & + flux_height, maxgoodqc, verbose + +!----------------------------------------------------------------------- +! globally-scoped variables +!----------------------------------------------------------------------- + +character(len=256) :: input_line, string1, string2, string3 +integer :: nmlfileunit, iline, nlines +logical :: file_exist, first_obs +integer :: n, i, oday, osec, rcio, iunit +integer :: num_copies, num_qc, max_obs +real(r8) :: oerr, qc +type(obs_sequence_type) :: obs_seq +type(obs_type) :: obs, prev_obs +type(time_type) :: time_obs, prev_time, offset + +type towerdata + type(time_type) :: time_obs + character(len=20) :: monthstring = 'month' + character(len=20) :: daystring = 'day' + character(len=20) :: hourstring = 'hour' + character(len=20) :: doystring = 'doy' + character(len=20) :: neestring = 'nee_or_fmds' + character(len=20) :: neeQCstring = 'nee_or_fmdsqc' + character(len=20) :: lestring = 'le_f' + character(len=20) :: leQCstring = 'le_fqc' + character(len=20) :: hstring = 'h_f' + character(len=20) :: hQCstring = 'h_fqc' + integer :: monthindex + integer :: dayindex + integer :: hourindex + integer :: doyindex + integer :: neeindex + integer :: neeQCindex + integer :: leindex + integer :: leQCindex + integer :: hindex + integer :: hQCindex + integer :: month + integer :: day + real(r8) :: hour + real(r8) :: doy + real(r8) :: nee + integer :: neeQC + real(r8) :: le + integer :: leQC + real(r8) :: h + integer :: hQC +end type towerdata + +type(towerdata) :: tower + +!----------------------------------------------------------------------- +! start of executable code +!----------------------------------------------------------------------- + +call initialize_utilities('level4_to_obs') + +! Print module information to log file and stdout. +call register_module(source, revision, revdate) + +! Read the namelist entry +call find_namelist_in_file("input.nml", "level4_to_obs_nml", iunit) +read(iunit, nml = level4_to_obs_nml, iostat = rcio) +call check_namelist_read(iunit, rcio, "level4_to_obs_nml") + +! Record the namelist values used for the run ... +if (do_nml_file()) write(nmlfileunit, nml=level4_to_obs_nml) +if (do_nml_term()) write( * , nml=level4_to_obs_nml) + +! time setup +call set_calendar_type(GREGORIAN) +offset = set_time(nint(abs(timezoneoffset)*3600.0_r8),0) + +if (verbose) print *, 'tower located at lat, lon, elev =', latitude, longitude, elevation +if (verbose) print *, 'flux observations taken at =', flux_height,'m' + +! check the lat/lon values to see if they are ok +if (longitude < 0.0_r8) longitude = longitude + 360.0_r8 + +if (( latitude > 90.0_r8 .or. latitude < -90.0_r8 ) .or. & + (longitude < 0.0_r8 .or. longitude > 360.0_r8 )) then + + write (string2,*)'latitude should be [-90, 90] but is ',latitude + write (string3,*)'longitude should be [ 0,360] but is ',longitude + + string1 ='tower location error in input.nml&level4_to_obs_nml' + call error_handler(E_ERR,'level4_to_obs', string1, source, revision, & + revdate, text2=string2,text3=string3) + +endif + +! We need to know the maximum number of observations in the input file. +! Each line has info for the 3 observations we want. +! The max possible number of obs needs to be specified but it +! will only write out the actual number created. +! Each observation in this series will have a single +! observation value and a quality control flag. +! Initialize two empty observations - one to track location +! in observation sequence - the other is for the new observation. + +iunit = open_file(text_input_file, 'formatted', 'read') +if (verbose) print *, 'opened input file ' // trim(text_input_file) + +nlines = count_file_lines(iunit) +max_obs = 3*nlines +num_copies = 1 +num_qc = 1 +first_obs = .true. + +call static_init_obs_sequence() +call init_obs(obs, num_copies, num_qc) +call init_obs(prev_obs, num_copies, num_qc) +call init_obs_sequence(obs_seq, num_copies, num_qc, max_obs) + +! the first one needs to contain the string 'observation' and the +! second needs the string 'QC'. +call set_copy_meta_data(obs_seq, 1, 'observation') +call set_qc_meta_data( obs_seq, 1, 'Ameriflux QC') + +! The first line describes all the fields ... column headers, if you will + +rewind(iunit) +call decode_header(iunit) + +obsloop: do iline = 2,nlines + + ! read in entire text line into a buffer + read(iunit,'(A)',iostat=rcio) input_line + if (rcio < 0) exit obsloop + if (rcio > 0) then + write (string1,'(''Cannot read (error '',i3,'') line '',i8,'' in '',A)') & + rcio, iline, trim(text_input_file) + call error_handler(E_ERR,'count_file_lines', string1, source, revision, revdate) + endif + + ! parse the line into the tower structure (including the observation time) + call stringparse(input_line,iline) + + if (iline <= 2) then + write(*,*)'' + write(*,*)'Check of the first observation: (column,string,value)' + write(*,*)tower%monthindex, tower%monthstring , tower%month + write(*,*)tower%dayindex , tower%daystring , tower%day + write(*,*)tower%hourindex , tower%hourstring , tower%hour + write(*,*)tower%doyindex , tower%doystring , tower%doy + write(*,*)tower%hindex , tower%hstring , tower%h + write(*,*)tower%hQCindex , tower%hQCstring , tower%hQC + write(*,*)tower%leindex , tower%lestring , tower%le + write(*,*)tower%leQCindex , tower%leQCstring , tower%leQC + write(*,*)tower%neeindex , tower%neestring , tower%nee + write(*,*)tower%neeQCindex, tower%neeQCstring , tower%neeQC + call print_date(tower%time_obs, 'observation date is') + call print_time(tower%time_obs, 'observation time is') + end if + + if (verbose) call print_date(tower%time_obs, 'obs time is') + + call get_time(tower%time_obs, osec, oday) + + ! make an obs derived type, and then add it to the sequence + ! If the QC value is good, use the observation. + ! Increasingly larger QC values are more questionable quality data. + + if (tower%hQC <= maxgoodqc) then + oerr = tower%h * 0.1_r8 ! total guess + qc = real(tower%hQC,r8) + call create_3d_obs(latitude, longitude, flux_height, VERTISHEIGHT, tower%h, & + TOWER_LATENT_HEAT_FLUX, oerr, oday, osec, qc, obs) + call add_obs_to_seq(obs_seq, obs, tower%time_obs, prev_obs, prev_time, first_obs) + endif + + if (tower%leQC <= maxgoodqc) then + oerr = tower%le * 0.1_r8 ! total guess + qc = real(tower%leQC,r8) + call create_3d_obs(latitude, longitude, flux_height, VERTISHEIGHT, tower%le, & + TOWER_SENSIBLE_HEAT_FLUX, oerr, oday, osec, qc, obs) + call add_obs_to_seq(obs_seq, obs, tower%time_obs, prev_obs, prev_time, first_obs) + endif + + if (tower%neeQC <= maxgoodqc) then + oerr = tower%NEE * 0.1_r8 ! total guess + qc = real(tower%neeQC,r8) + call create_3d_obs(latitude, longitude, flux_height, VERTISHEIGHT, tower%Nee, & + TOWER_NETC_ECO_EXCHANGE, oerr, oday, osec, qc, obs) + call add_obs_to_seq(obs_seq, obs, tower%time_obs, prev_obs, prev_time, first_obs) + endif + +end do obsloop + +! if we added any obs to the sequence, write it out to a file now. +if ( get_num_obs(obs_seq) > 0 ) then + if (verbose) print *, 'writing obs_seq, obs_count = ', get_num_obs(obs_seq) + call write_obs_seq(obs_seq, obs_out_file) +endif + +! end of main program +call finalize_utilities() + +contains + + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! +! create_3d_obs - subroutine that is used to create an observation +! type from observation data. +! +! NOTE: assumes the code is using the threed_sphere locations module, +! that the observation has a single data value and a single +! qc value, and that this obs type has no additional required +! data (e.g. gps and radar obs need additional data per obs) +! +! lat - latitude of observation +! lon - longitude of observation +! vval - vertical coordinate +! vkind - kind of vertical coordinate (pressure, level, etc) +! obsv - observation value +! okind - observation kind +! oerr - observation error +! day - gregorian day +! sec - gregorian second +! qc - quality control value +! obs - observation type +! +! created Oct. 2007 Ryan Torn, NCAR/MMM +! adapted for more generic use 11 Mar 2010, nancy collins, ncar/image +! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +subroutine create_3d_obs(lat, lon, vval, vkind, obsv, okind, oerr, day, sec, qc, obs) +use obs_def_mod, only : obs_def_type, set_obs_def_time, set_obs_def_kind, & + set_obs_def_error_variance, set_obs_def_location +use obs_sequence_mod, only : obs_type, set_obs_values, set_qc, set_obs_def +use time_manager_mod, only : time_type, set_time +use location_mod, only : set_location + + integer, intent(in) :: okind, vkind, day, sec + real(r8), intent(in) :: lat, lon, vval, obsv, oerr, qc + type(obs_type), intent(inout) :: obs + +real(r8) :: obs_val(1), qc_val(1) +type(obs_def_type) :: obs_def + +call set_obs_def_location(obs_def, set_location(lon, lat, vval, vkind)) +call set_obs_def_kind(obs_def, okind) +call set_obs_def_time(obs_def, set_time(sec, day)) +call set_obs_def_error_variance(obs_def, oerr * oerr) +call set_obs_def(obs, obs_def) + +obs_val(1) = obsv +call set_obs_values(obs, obs_val) +qc_val(1) = qc +call set_qc(obs, qc_val) + +end subroutine create_3d_obs + + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! +! add_obs_to_seq -- adds an observation to a sequence. inserts if first +! obs, inserts with a prev obs to save searching if that's possible. +! +! seq - observation sequence to add obs to +! obs - observation, already filled in, ready to add +! obs_time - time of this observation, in dart time_type format +! prev_obs - the previous observation that was added to this sequence +! (will be updated by this routine) +! prev_time - the time of the previously added observation (will also +! be updated by this routine) +! first_obs - should be initialized to be .true., and then will be +! updated by this routine to be .false. after the first obs +! has been added to this sequence. +! +! created Mar 8, 2010 nancy collins, ncar/image +! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +subroutine add_obs_to_seq(seq, obs, obs_time, prev_obs, prev_time, first_obs) + +use obs_sequence_mod, only : obs_sequence_type, obs_type, insert_obs_in_seq +use time_manager_mod, only : time_type, operator(>=) + +type(obs_sequence_type), intent(inout) :: seq +type(obs_type), intent(inout) :: obs, prev_obs +type(time_type), intent(in) :: obs_time +type(time_type), intent(inout) :: prev_time +logical, intent(inout) :: first_obs + +! insert(seq,obs) always works (i.e. it inserts the obs in +! proper time format) but it can be slow with a long file. +! supplying a previous observation that is older (or the same +! time) as the new one speeds up the searching a lot. + +if(first_obs) then ! for the first observation, no prev_obs + call insert_obs_in_seq(seq, obs) + first_obs = .false. +else + if(obs_time >= prev_time) then ! same time or later than previous obs + call insert_obs_in_seq(seq, obs, prev_obs) + else ! earlier, search from start of seq + call insert_obs_in_seq(seq, obs) + endif +endif + +! update for next time +prev_obs = obs +prev_time = obs_time + +end subroutine add_obs_to_seq + + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! +! count_file_lines -- +! count the lines in a text file. +! rewinds the unit after counting. +! +! iunit - handle to the already-open text file +! +! created May 2, 2012 Tim Hoar, NCAR/IMAGe +! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +function count_file_lines(iunit) + +integer, intent(in) :: iunit +integer :: count_file_lines + +integer :: i +character(len=128) :: oneline + +integer, parameter :: tenmillion = 10000000 +rewind(iunit) + +count_file_lines = 0 +countloop : do i = 1,tenmillion + + read(iunit,'(A)',iostat=rcio) oneline + + if (rcio < 0) exit countloop ! end of file + if (rcio > 0) then + write (string1,'('' read around line '',i8)')i + call error_handler(E_ERR,'count_file_lines', string1, & + source, revision, revdate) + endif + count_file_lines = count_file_lines + 1 + +enddo countloop +rewind(iunit) + +if (count_file_lines >= tenmillion) then + write (string1,'('' suspiciously large number of lines '',i8)')count_file_lines + call error_handler(E_MSG,'count_file_lines', string1, & + source, revision, revdate) +endif + +end function count_file_lines + + + + +subroutine decode_header(iunit) +! Reads the first line of the header and parses the information. +integer, intent(in) :: iunit + +read(iunit,'(A)',iostat=rcio) input_line +if (rcio /= 0) then + write(string1,*)'Cannot parse header. Begins <',trim(input_line(1:40)),'>' + call error_handler(E_ERR,'decode_header',string1, source, revision, revdate) +endif + +call error_handler(E_MSG,'decode_header','hardcoding values for now ... dangerous', & + source, revision, revdate) + +tower%monthindex = 1 +tower%dayindex = 2 +tower%hourindex = 3 +tower%doyindex = 4 +tower%hindex = 15 +tower%hQCindex = 16 +tower%leindex = 17 +tower%leQCindex = 18 +tower%neeindex = 26 +tower%neeQCindex = 27 + +end subroutine decode_header + + + +subroutine stringparse(str1,linenum) +! just declare everything as reals and see how it falls out + +character(len=*), intent(in) :: str1 +integer , intent(in) :: linenum + +real(r8), dimension(34) :: values +integer :: ihour, imin, isec, seconds + +values = MISSING_R8 + +read(str1,*,iostat=rcio) values +if (rcio /= 0) then + write(string1,*)'Cannot parse line',linenum,'. Begins <',trim(str1(1:40)),'>' + call error_handler(E_ERR,'stringparse',string1, source, revision, revdate) +endif + +! Stuff what we want into the tower structure +! +! Convert to 'CLM-friendly' units. +! NEE_or_fMDS has units [umolCO2 m-2 s-1] +! H_f has units [W m-2] +! LE_f has units [W m-2] +! +! (CLM) NEE has units [gC m-2 s-1] + +tower%month = nint(values(tower%monthindex)) +tower%day = nint(values(tower%dayindex )) +tower%hour = values(tower%hourindex ) +tower%doy = values(tower%doyindex ) +tower%nee = values(tower%neeindex ) * 12.0_r8 * 1000000.0_r8 +tower%neeQC = nint(values(tower%neeQCindex)) +tower%le = values(tower%leindex ) +tower%leQC = nint(values(tower%leQCindex )) +tower%h = values(tower%hindex ) +tower%hQC = nint(values(tower%hQCindex )) + +! put observation time/date into a dart time format + +ihour = int(tower%hour) +seconds = nint((tower%hour - real(ihour,r8))*3600) +imin = seconds / 60 +isec = seconds - imin * 60 + +tower%time_obs = set_date(year, tower%month, tower%day, ihour, imin, isec) + +if (timezoneoffset < 0.0_r8) then + tower%time_obs = tower%time_obs - offset +else + tower%time_obs = tower%time_obs + offset +endif + + +end subroutine stringparse + + + +end program level4_to_obs + + +! LEVEL 4 VARIABLE DESCRIPTION +! +! Variables description: +! Level 4 data are obtained from the level 3 products, data are ustar filtered, +! gap-filled using different methods and partitioned. +! Datasets are also aggregated from daily to monthly. +! Flags with information regarding quality of the original and gapfilled data are added. +! +! Half hourly dataset variables description: +! +! - Month : from 1 to 12 +! - Day : day of the month +! - Hour : from 0 to 23.5, indicates the end of the half hour of measurement +! - DoY : decimal day of the year +! - Rg_f : global radiation filled [W m-2] +! - Rg_fqc : global radiation quality flags: +! 0 = original, 1 = A (most reliable), 2 = B (medium), 3 = C (least reliable). +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! - Ta_f : air temperature filled [\xB0C] +! - Ta_fqc : air temperature quality flags: +! 0 = original, 1 = A (most reliable), 2 = B (medium), 3 = C (least reliable). +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! - VPD_f : vapour pressure deficit [hPa] +! - VPD_fqc : vapour pressure deficit quality flags: +! 0 = original, 1 = A (most reliable), 2 = B (medium), 3 = C (least reliable). +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! - Ts_f : soil temperature filled [\xB0C] +! - Ts_fqc : soil temperature quality flags: +! 0 = original, 1 = A (most reliable), 2 = B (medium), 3 = C (least reliable). +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! - Precip : precipitation [mm] +! - SWC : soil water content [%vol] +! - H_f : sensible heat flux filled [W m-2] +! - H_fqc : sensible heat flux quality flags: +! 0 = original, 1 = A (most reliable), 2 = B (medium), 3 = C (least reliable). +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! - LE_f : latent heat flux filled [W m-2] +! - LE_fqc : latent heat flux quality flags: +! 0 = original, 1 = A (most reliable), 2 = B (medium), 3 = C (least reliable). +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! - qf_NEE_st : fluxes quality flags as defined in the Level3 product +! - qf_NEE_or : fluxes quality flags as defined in the Level3 product +! - Reco_st : Estimated ecosystem respiration according to the short-term temperature +! response of night-time fluxes based on NEE_st +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! [umolCO2 m-2 s-1] +! - Reco_or : Estimated ecosystem respiration according to the short-term temperature +! response of night-time fluxes based on NEE_or +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! [umolCO2 m-2 s-1] +! - NEE_st_fMDS : NEE_st filled using the Marginal Distribution Sampling method +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! [umolCO2 m-2 s-1] +! - NEE_st_fMDSqc : NEE_st_fMDS quality flags: +! 0 = original, 1 = A (most reliable), 2 = B (medium), 3 = C (least reliable). +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! - GPP_st_MDS : Gross Primary Production calculated as GPP_st_MDS = Reco_st - NEE_st_MDS +! [umolCO2 m-2 s-1] +! - NEE_or_fMDS : NEE_or filled using the Marginal Distribution Sampling method +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! [umolCO2 m-2 s-1] +! - NEE_or_fMDSqc : NEE_or_fMDS quality flags: +! 0 = original, 1 = A (most reliable), 2 = B (medium), 3 = C (least reliable). +! (Refer to Reichstein et al. 2005 Global Change Biology ) +! - GPP_or_MDS : Gross Primary Production calculated as GPP_or_MDS = Reco_or - NEE_or_MDS +! [umolCO2 m-2 s-1] +! - NEE_st_fANN : NEE_st filled using the Artificial Neural Network method +! (Refer to Papale et al. 2003 Global Change Biology and to the Other Information section in this document) +! [umolCO2 m-2 s-1] +! - NEE_st_fANNqc : NEE_st_fANN quality flags: +! 0 = original, 1 = filled using original meteorological inputs or filled with qc=1, +! 2 = filled using filled meteorological inputs with qc=2 or 3, +! 3 = not filled using ANN due to one or more input missed but filled with the MDS method +! - GPP_st_ANN : Gross Primary Production calculated as GPP_st_ ANN = Reco_st - NEE_st_ ANN +! [umolCO2 m-2 s-1] +! - NEE_or_f ANN : NEE_or filled using the Artificial Neural Network method +! (Refer to Papale et al. 2003 Global Change Biology and to the Other Information section in this document) +! [umolCO2 m-2 s-1] +! - NEE_or_f ANNqc : NEE_or_fANN quality flags: +! 0 = original, 1 = filled using original meteorological inputs or filled with qc=1, +! 2 = filled using filled meteorological inputs with qc=2 or 3, +! 3 = not filled using ANN due to one or more input missed but filled with the MDS method +! - GPP_or_ ANN : Gross Primary Production calculated as GPP_or_ ANN = Reco_or - NEE_or_ ANN +! [umolCO2 m-2 s-1] Property changes on: DART/branches/development/observations/Ameriflux/level4_to_obs.f90 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Rev Author HeadURL Id Added: svn:eol-style + native Added: DART/branches/development/observations/Ameriflux/level4_to_obs.html =================================================================== --- DART/branches/development/observations/Ameriflux/level4_to_obs.html (rev 0) +++ DART/branches/development/observations/Ameriflux/level4_to_obs.html 2012-05-08 20:27:20 UTC (rev 5713) @@ -0,0 +1,380 @@ + + + +program level4_to_obs + + + + + + +

    PROGRAM level4_to_obs

    + + + + + + +
    + DART project logo + +

    Jump to DART Documentation Main Index
    + version information for this file:
    + + $Id$
    +

    + +NAMELIST / +DATA SOURCES / +PROGRAMS / +DECISIONS / +REFERENCES / +ERRORS / +PLANS / +TERMS OF USE + +

    Overview

    + +

    AmeriFlux Level 4 data to DART Observation Sequence Converter

    + +

    This routine is designed to convert the flux tower Level 4 data +from the AmeriFlux +network of observations from micrometeorological tower sites. +AmeriFlux is part of FLUXNET +and the converter is hoped to be a suitable starting point for the conversion +of observations from FLUXNET. As of May 2012, I have not yet tried to work with +any other observations from FLUXNET. +
    +
    +The AmeriFlux Level 4 products are recorded using the local time. +DART observation sequence files use GMT. For more information about +AmeriFlux data products, go to + +http://public.ornl.gov/ameriflux/dataproducts.shtml. +

    + +

    +The workflow is usually: +

    +
      +
    1. download the Level 4 data for the towers and years in question + (see DATA SOURCES below) +
    2. record the TIME ZONE, latitude, longitude, and elevation for each tower +
    3. build the DART executables with support for the tower observations. + This is done by running preprocess with + obs_def_tower_mod.f90 in the list of input_files + for preprocess_nml. +
    4. provide basic tower information via the level4_to_obs_nml namelist + since this information is not contained in the Level 4 data file
    5. +
    6. convert each Level 4 data file individually using level4_to_obs
    7. +
    8. combine all output files for the region and timeframe of interest into one file + using obs_sequence_tool
    9. +
    + +

    +For some models (CLM, for example), it is required to reorganize the observation sequence +files into a series of files that contains ONLY the observations for each assimilation. +This can be achieved with the makedaily.sh script. +

    + + + + + + +
    +

    NAMELIST

    +

    We adhere to the F90 standard of starting a namelist with an ampersand +'&' and terminating with a slash '/' for all our namelist input. +

    +
    +
    +namelist /level4_to_obs_nml/  text_input_file, obs_out_file, year, &
    +             timezoneoffset, latitude, longitude, elevation, inst_height, maxgoodqc, verbose
    +
    +
    + +

    Discussion

    + +

    This namelist is read in a file called input.nml. +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Contents Type Description
    text_input_file character(len=128) Name of the Level 4 ASCII file of comma-separated values. + This may be a relative or absolute filename.
    + Default: 'textdata.input'
    obs_out_file character(len=128) Name of the output observation sequence file.
    + Default: 'obs_seq.out'
    year integer The year of the observations in the Level 4 text file.
    + Default: none
    timezoneoffset real the time zone offset (in hours) of the station. + The tower observation times are local time, we need to convert them + to GMT.
    + Default: none
    latitude real Latitude (in degrees N) of the tower.
    + Default: none
    longitude real Longitude (in degrees E) of the tower. + For internal consistency, DART uses longitudes in the range [0,360]. + An input value of -90 will be converted to 270.
    + Default: none
    elevation real surface elevation (in meters) of the tower.
    + Default: none
    flux_height real height (in meters) of the flux instrument on the tower.
    + Default: none
    maxgoodqc real maximum value of any observation quality control flag to + pass through to the output observation sequence. Keep in mind that + filter has the ability to discriminate on the + value, so there is really little to be gained by rejecting them + during the conversion.
    + Default: 3
    verbose logical Print extra information about the level4_to_obs run.
    + Default: .false.
    + + + + + +
    +

    DATA SOURCES

    + +

    +The data was acquired from + +http://public.ornl.gov/ameriflux/dataproducts.shtm
    +
    +The Level 4 products in question are ASCII files of comma-separated values taken +every 30 minutes for an entire year. The first line is a comma-separated list of +column descriptors, all subsequent lines are comma-separated numerical values. +The converter presently searches for the columns pertaining to NEE_or_fMDS, +H_f, LE_f, their corresponding quality control fields, +and those columns pertaining to the time of the observation. +These values are mapped as follows: +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Level 4 units Level 4 variabledescription DART type DART kind DART units

    W/m^2 LE_f Latent Heat Flux TOWER_LATENT_HEAT_FLUX KIND_LATENT_HEAT_FLUX W/m^2
    [0-3] LE_fqc QC for LE_f N/A N/A same

    W/m^2 H_f Sensible Heat Flux TOWER_SENSIBLE_HEAT_FLUX KIND_SENSIBLE_HEAT_FLUX W/m^2
    [0-3] H_fqc QC for H_f N/A N/A same

    umolCO2/m^2/s NEE_or_fMDS Net Ecosystem Production TOWER_NETC_ECO_EXCHANGE KIND_NET_CARBON_PRODUCTION gC/m^2/s
    [0-3] NEE_or_fMDSqc QC for NEE_or_fMDS N/A N/A same
    + +

    The LE_fqc, H_fqc, and NEE_or_fMDSqc variables use the following convention:
    +

    +0 = original, 1 = category A (most reliable), 2 = category B (medium), 3 = category C (least reliable). (Refer to Reichstein et al. 2005 Global Change Biology for more information)
    +
    +
    +I am repeating the AmeriFlux +Data Fair-Use Policy because I believe it is important to be a good scientific citizen: + +
    +The AmeriFlux data ... are freely available and were furnished by +individual AmeriFlux scientists who encourage their use. Please kindly inform in +writing (or e-mail) the appropriate AmeriFlux scientist(s) of how you intend to use +the data and of any publication plans. It is also important to contact the AmeriFlux +investigator to assure you are downloading the latest revision of the data and to +prevent potential misuse or misinterpretation of the data. Please acknowledge the +data source as a citation or in the acknowledgments if no citation is available. +If the AmeriFlux Principal Investigators (PIs) feel that they should be +acknowledged or offered participation as authors, they will let you know and we +assume that an agreement on such matters will be reached before publishing and/or +use of the data for publication. If your work directly competes with the PI's +analysis they may ask that they have the opportunity to submit a manuscript before +you submit one that uses unpublished data. In addition, when publishing please +acknowledge the agency that supported the research. Lastly, we kindly request that +those publishing papers using AmeriFlux data provide reprints to the PIs providing +the data and to the data archive at the Carbon Dioxide Information Analysis Center +(CDIAC).
    +

    + + + + +
    +

    PROGRAMS

    +

    +The level4_to_obs.f90 file is the source +for the main converter program. +Look at the source code where it reads the example data file. You will +almost certainly need to change the "read" statement to match your data +format. The example code +reads each text line into a character buffer +and then reads from that buffer to parse up the data items. +

    +To compile and test, +go into the work subdirectory and run the quickbuild.csh +script to build the converter and a couple of general purpose utilities. +advance_time helps with calendar and time computations, +and the +obs_sequence_tool manipulates DART observation files +once they have been created. +

    +

    +To change the observation types, look in the +DART/obs_def directory. If you can +find an obs_def_XXX_mod.f90 file with an appropriate set +of observation types, change the 'use' lines in the converter +source to include those types. Then add that filename in the +input.nml namelist file +to the &preprocess_nml namelist, the 'input_files' variable. +Multiple files can be listed. Then run quickbuild.csh again. +It remakes the table of supported observation types before +trying to recompile the source code. +

    +

    +An example script for converting batches of files is +in the shell_scripts directory. A tiny example +data file is in the data directory. +These are NOT intended to be turnkey scripts; they will +certainly need to be customized for your use. There are comments +at the top of the script saying what options they include, and +should be commented enough to indicate where changes will be +likely to need to be made. +

    + + + + +
    +

    DECISIONS YOU MIGHT NEED TO MAKE

    + +

    +See the discussion in the +observations introduction +page about what options are available for the things you need to +specify. These include setting a time, specifying an expected error, +setting a location, and an observation type. +

    + + + + + + +
    +

    KNOWN BUGS

    +

    +none +

    + + + + + + +
    +

    FUTURE PLANS

    +

    +none +

    + + + + + + @@ Diff output truncated at 40000 characters. @@ From nancy at ucar.edu Tue May 8 14:59:02 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Tue, 08 May 2012 14:59:02 -0600 Subject: [Dart-dev] [5714] DART/branches/development/observations/Ameriflux/level4_to_obs.html: a little micro-managing Message-ID: Revision: 5714 Author: thoar Date: 2012-05-08 14:59:02 -0600 (Tue, 08 May 2012) Log Message: ----------- a little micro-managing Modified Paths: -------------- DART/branches/development/observations/Ameriflux/level4_to_obs.html -------------- next part -------------- Modified: DART/branches/development/observations/Ameriflux/level4_to_obs.html =================================================================== --- DART/branches/development/observations/Ameriflux/level4_to_obs.html 2012-05-08 20:27:20 UTC (rev 5713) +++ DART/branches/development/observations/Ameriflux/level4_to_obs.html 2012-05-08 20:59:02 UTC (rev 5714) @@ -65,7 +65,7 @@ This is done by running preprocess with obs_def_tower_mod.f90 in the list of input_files for preprocess_nml. -
  • provide basic tower information via the level4_to_obs_nml namelist +
  • provide basic tower information via the level4_to_obs_nml namelist since this information is not contained in the Level 4 data file
  • convert each Level 4 data file individually using level4_to_obs
  • combine all output files for the region and timeframe of interest into one file @@ -137,7 +137,7 @@ real Longitude (in degrees E) of the tower. For internal consistency, DART uses longitudes in the range [0,360]. - An input value of -90 will be converted to 270.
    + An input value of -90 will be converted to 270, for example.
    Default: none elevation @@ -161,7 +161,8 @@ verbose logical - Print extra information about the level4_to_obs run.
    + Print extra information during the level4_to_obs + execution.
    Default: .false. @@ -367,7 +368,7 @@

    - + From nancy at ucar.edu Wed May 9 09:57:09 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 09:57:09 -0600 Subject: [Dart-dev] [5727] DART/branches: CLM is ready to move onto the development branch. Message-ID: Revision: 5727 Author: thoar Date: 2012-05-09 09:57:08 -0600 (Wed, 09 May 2012) Log Message: ----------- CLM is ready to move onto the development branch. The vertical interpolation still needs work. The snow water equivalent update process still needs work. The observation operator for the flux tower observations has not even been started. Added Paths: ----------- DART/branches/development/models/clm/ Removed Paths: ------------- DART/branches/clm/models/clm/ -------------- next part -------------- Property changes on: DART/branches/development/models/clm ___________________________________________________________________ Added: svn:mergeinfo + /DART/trunk/models/clm:5026-5063 From nancy at ucar.edu Wed May 9 10:04:44 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 10:04:44 -0600 Subject: [Dart-dev] [5728] DART/branches/development/models/simple_advection/work/ workshop_setup.csh: Removed a premature exit that made it behave like it was Message-ID: Revision: 5728 Author: thoar Date: 2012-05-09 10:04:43 -0600 (Wed, 09 May 2012) Log Message: ----------- Removed a premature exit that made it behave like it was quickbuild.csh - i.e. it prevented the execution of perfect_model_obs and filter. Modified Paths: -------------- DART/branches/development/models/simple_advection/work/workshop_setup.csh -------------- next part -------------- Modified: DART/branches/development/models/simple_advection/work/workshop_setup.csh =================================================================== --- DART/branches/development/models/simple_advection/work/workshop_setup.csh 2012-05-09 15:57:08 UTC (rev 5727) +++ DART/branches/development/models/simple_advection/work/workshop_setup.csh 2012-05-09 16:04:43 UTC (rev 5728) @@ -87,8 +87,6 @@ endsw end -exit - @ n = $n + 1 ./perfect_model_obs || exit $n From nancy at ucar.edu Wed May 9 10:06:00 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 10:06:00 -0600 Subject: [Dart-dev] [5729] DART/branches/development/models/NAAPS/work/: added property changes ... Message-ID: Revision: 5729 Author: thoar Date: 2012-05-09 10:05:59 -0600 (Wed, 09 May 2012) Log Message: ----------- added property changes ... svn:ignore Property Changed: ---------------- DART/branches/development/models/NAAPS/work/ -------------- next part -------------- Property changes on: DART/branches/development/models/NAAPS/work ___________________________________________________________________ Added: svn:ignore + .cppdefs create_fixed_network_seq create_obs_sequence dart_log.nml dart_log.out dart_to_naaps filter input.nml.create_fixed_network_seq_default input.nml.create_obs_sequence_default input.nml.dart_to_naaps_default input.nml.filter_default input.nml.model_mod_check_default input.nml.naaps_to_dart_default input.nml.obs_diag_default input.nml.obs_seq_to_netcdf_default input.nml.obs_sequence_tool_default input.nml.perfect_model_obs_default input.nml.preprocess_default input.nml.restart_file_tool_default input.nml.wakeup_filter_default Makefile model_mod_check naaps_to_dart obs_diag obs_seq_to_netcdf obs_sequence_tool perfect_model_obs preprocess restart_file_tool wakeup_filter From nancy at ucar.edu Wed May 9 10:54:17 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 10:54:17 -0600 Subject: [Dart-dev] [5730] DART/branches: Moving the snow observation tools to the development branch. Message-ID: Revision: 5730 Author: thoar Date: 2012-05-09 10:54:17 -0600 (Wed, 09 May 2012) Log Message: ----------- Moving the snow observation tools to the development branch. Added Paths: ----------- DART/branches/development/observations/snow/ Removed Paths: ------------- DART/branches/clm/observations/snow/ -------------- next part -------------- Property changes on: DART/branches/development/observations/snow ___________________________________________________________________ Added: svn:mergeinfo + /DART/trunk/observations/snow:5026-5063 From nancy at ucar.edu Wed May 9 15:36:00 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 15:36:00 -0600 Subject: [Dart-dev] [5732] DART/branches: Moving CLM matlab support routine into development branch. Message-ID: Revision: 5732 Author: thoar Date: 2012-05-09 15:36:00 -0600 (Wed, 09 May 2012) Log Message: ----------- Moving CLM matlab support routine into development branch. Added Paths: ----------- DART/branches/development/matlab/GetClmInfo.m Removed Paths: ------------- DART/branches/clm/matlab/GetClmInfo.m -------------- next part -------------- Deleted: DART/branches/clm/matlab/GetClmInfo.m =================================================================== --- DART/branches/clm/matlab/GetClmInfo.m 2012-05-09 19:48:53 UTC (rev 5731) +++ DART/branches/clm/matlab/GetClmInfo.m 2012-05-09 21:36:00 UTC (rev 5732) @@ -1,349 +0,0 @@ -function pinfo = GetClmInfo(pstruct,fname,routine) -%% GetClmInfo prepares a structure of information needed by the subsequent "routine" -% The information is gathered via rudimentary "input" routines. -% -% pinfo = GetClmInfo(pstruct,routine); -% -% pstruct structure containing the names of the truth_file and the diagn_file of the DART netcdf file -% routine name of subsequent plot routine. - -%% DART software - Copyright 2004 - 2011 UCAR. This open source software is -% provided by UCAR, "as is", without charge, subject to all terms of use at -% http://www.image.ucar.edu/DAReS/DART/DART_download -% -% -% $URL$ -% $Id$ -% $Revision$ -% $Date$ - -if (exist(fname,'file') ~= 2 ), error('%s does not exist.',fname); end - -pinfo = pstruct; -model = nc_attget(fname,nc_global,'model'); - -if strcmpi(model,'clm') ~= 1 - error('Not so fast, this is not a clm model.') -end - -%% Get the domain-independent information. - -varexist(fname, {'copy','time'}) - -copy = nc_varget(fname,'copy'); -times = nc_varget(fname,'time'); - -% Coordinate between time types and dates - -timeunits = nc_attget(fname,'time','units'); -timebase = sscanf(timeunits,'%*s%*s%d%*c%d%*c%d'); % YYYY MM DD -timeorigin = datenum(timebase(1),timebase(2),timebase(3)); -dates = times + timeorigin; - -levels = nc_varget(fname, 'levgrnd'); % coordinate soil levels (usually 15) -lon = nc_varget(fname, 'lon'); -lat = nc_varget(fname, 'lat'); - -switch lower(deblank(routine)) - - case {'plotbins','plotenserrspread','plotensmeantimeseries','plotenstimeseries'} - - base_var = GetVar(pinfo.vars, pinfo.vars{1}); % Determine prognostic variable - [level, lvlind] = GetLevel(pinfo.fname, base_var); % Determine level and index - [lat , latind] = GetLatitude(lat); - [lon , lonind] = GetLongitude(lon); - - pinfo.model = model; - pinfo.times = dates; - pinfo.var = base_var; - pinfo.level = level; - pinfo.levelindex = lvlind; - pinfo.longitude = lon; - pinfo.lonindex = lonind; - pinfo.latitude = lat; - pinfo.latindex = latind; - - case 'plotcorrel' - - disp('Getting information for the ''base'' variable.') - base_var = GetVar(pinfo.vars, pinfo.vars{1}); - [base_time, base_tmeind] = GetTime(dates); - [base_lvl, base_lvlind] = GetLevel(pinfo.fname, base_var); - [base_lat, base_latind] = GetLatitude(lat); - [base_lon, base_lonind] = GetLongitude(lon); - - disp('Getting information for the ''comparison'' variable.') - comp_var = GetVar(pinfo.vars, base_var); - [comp_lvl, comp_lvlind] = GetLevel(pinfo.fname, comp_var, base_lvlind); - - pinfo.model = model; - pinfo.times = dates; - pinfo.base_var = base_var; - pinfo.comp_var = comp_var; - pinfo.base_time = base_time; - pinfo.base_tmeind = base_tmeind; - pinfo.base_lvl = base_lvl; - pinfo.base_lvlind = base_lvlind; - pinfo.base_lat = base_lat; - pinfo.base_latind = base_latind; - pinfo.base_lon = base_lon; - pinfo.base_lonind = base_lonind; - pinfo.comp_lvl = comp_lvl; - pinfo.comp_lvlind = comp_lvlind; - - case 'plotvarvarcorrel' - - disp('Getting information for the ''base'' variable.') - base_var = GetVar(pinfo.vars, pinfo.vars{1}); - [base_time, base_tmeind] = GetTime(dates); - [base_lvl , base_lvlind] = GetLevel(pinfo.fname, base_var); - [base_lat , base_latind] = GetLatitude(lat); - [base_lon , base_lonind] = GetLongitude(lon); - - disp('Getting information for the ''comparison'' variable.') - comp_var = GetVar(pinfo.vars, base_var); - [comp_lvl, comp_lvlind] = GetLevel(pinfo.fname, comp_var, base_lvlind); - [comp_lat, comp_latind] = GetLatitude( lat, base_lat); - [comp_lon, comp_lonind] = GetLongitude(lon, base_lon); - - pinfo.model = model; - pinfo.times = dates; - pinfo.base_var = base_var; - pinfo.comp_var = comp_var; - pinfo.base_time = base_time; - pinfo.base_tmeind = base_tmeind; - pinfo.base_lvl = base_lvl; - pinfo.base_lvlind = base_lvlind; - pinfo.base_lat = base_lat; - pinfo.base_latind = base_latind; - pinfo.base_lon = base_lon; - pinfo.base_lonind = base_lonind; - pinfo.comp_lvl = comp_lvl; - pinfo.comp_lvlind = comp_lvlind; - pinfo.comp_lat = comp_lat; - pinfo.comp_latind = comp_latind; - pinfo.comp_lon = comp_lon; - pinfo.comp_lonind = comp_lonind; - - - case 'plotsawtooth' - - pgvar = GetVar(pinfo.vars, pinfo.vars{1}); - [level, lvlind] = GetLevel(pinfo.fname, pgvar); - [ lat, latind] = GetLatitude( lat); - [ lon, lonind] = GetLongitude(lon); - % [ lon, lonind] = GetCopies(pgvar,xxx); - - pinfo.model = model; - pinfo.times = dates; - pinfo.var_names = pgvar; - pinfo.truth_file = []; - pinfo.prior_file = pstruct.prior_file; - pinfo.posterior_file = pstruct.posterior_file; - pinfo.level = level; - pinfo.levelindex = lvlind; - pinfo.latitude = lat; - pinfo.latindex = latind; - pinfo.longitude = lon; - pinfo.lonindex = lonind; - pinfo.copies = 0; - pinfo.copyindices = []; - - if ( exist(pstruct.truth_file,'file') ) - pinfo.truth_file = pstruct.truth_file; - end - - - case 'plotphasespace' - - disp('Getting information for the ''X'' variable.') - var1 = GetVar(pinfo.vars, pinfo.vars{1}); - [var1_lvl, var1_lvlind] = GetLevel(pinfo.fname, var1); - [var1_lat, var1_latind] = GetLatitude( lat ); - [var1_lon, var1_lonind] = GetLongitude(lon ); - - disp('Getting information for the ''Y'' variable.') - var2 = GetVar(pinfo.fname, pinfo.vars, var1 ); - [var2_lvl, var2_lvlind] = GetLevel(pinfo.fname, var2, var1_lvlind); - [var2_lat, var2_latind] = GetLatitude( lat, var1_lat); - [var2_lon, var2_lonind] = GetLongitude(lon, var1_lon); - - disp('Getting information for the ''Z'' variable.') - var3 = GetVar(pinfo.fname, pinfo.vars, var1 ); - [var3_lvl, var3_lvlind] = GetLevel(pinfo.fname, var3, var1_lvlind); - [var3_lat, var3_latind] = GetLatitude( lat, var1_lat); - [var3_lon, var3_lonind] = GetLongitude(lon, var1_lon); - - % query for ensemble member - s1 = input('Input ensemble member metadata STRING. for ''true state'' ','s'); - if isempty(s1), ens_mem = 'true state'; else ens_mem = s1; end - - % query for line type - s1 = input('Input line type string. for ''k-'' ','s'); - if isempty(s1), ltype = 'k-'; else ltype = s1; end - - pinfo.model = model; - pinfo.times = dates; - pinfo.var1name = var1; - pinfo.var2name = var2; - pinfo.var3name = var3; - pinfo.var1_lvl = var1_lvl; - pinfo.var1_lvlind = var1_lvlind; - pinfo.var1_lat = var1_lat; - pinfo.var1_latind = var1_latind; - pinfo.var1_lon = var1_lon; - pinfo.var1_lonind = var1_lonind; - pinfo.var2_lvl = var2_lvl; - pinfo.var2_lvlind = var2_lvlind; - pinfo.var2_lat = var2_lat; - pinfo.var2_latind = var2_latind; - pinfo.var2_lon = var2_lon; - pinfo.var2_lonind = var2_lonind; - pinfo.var3_lvl = var3_lvl; - pinfo.var3_lvlind = var3_lvlind; - pinfo.var3_lat = var3_lat; - pinfo.var3_latind = var3_latind; - pinfo.var3_lon = var3_lon; - pinfo.var3_lonind = var3_lonind; - pinfo.ens_mem = ens_mem; - pinfo.ltype = ltype; - - otherwise - -end - - -function pgvar = GetVar(prognostic_vars, pgvar) -%---------------------------------------------------------------------- - -str = sprintf(' %s ',prognostic_vars{1}); -for i = 2:length(prognostic_vars), - str = sprintf(' %s %s ',str,prognostic_vars{i}); -end -fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) -fprintf('If not, please enter one of: %s\n',str) -varstring = input('(no syntax required)\n','s'); - -if ~isempty(varstring), pgvar = strtrim(varstring); end -inds = strfind(pgvar,','); -pgvar(inds) = ''; - - - -function [time, timeind] = GetTime(times, deftime) -%---------------------------------------------------------------------- -% Query for the time of interest. - -ntimes = length(times); - -% Determine a sensible default. -if (nargin == 2), - time = deftime; - tindex = find(times == deftime); -else - if (ntimes < 2) - tindex = round(ntimes/2); - else - tindex = 1; - end - time = times(tindex); -end - -fprintf('Default time is %s (index %d), if this is OK, ;\n',datestr(time),tindex) -fprintf('If not, enter an index between %d and %d \n',1,ntimes) -fprintf('Pertaining to %s and %s \n',datestr(times(1)),datestr(times(ntimes))) -varstring = input('(no syntax required)\n','s'); - -if ~isempty(varstring), tindex = str2double(varstring); end - -timeinds = 1:ntimes; -d = abs(tindex - timeinds); % crude distance -ind = find(min(d) == d); % multiple minima possible -timeind = ind(1); % use the first one -time = times(timeind); - - - -function [level, lvlind] = GetLevel(fname, pgvar, deflevel) -%---------------------------------------------------------------------- -% level and lvlind will not be equal for all models, (and probably -% shouldn't for clm ... but for future expansion ... -if (nargin == 3), lvlind = deflevel; else lvlind = 1; end - -vinfo = nc_getvarinfo(fname,pgvar); -levdim = find(strncmpi(vinfo.Dimension,'lev',3)); -if ( isempty(levdim) ) - fprintf('''%s'' only has one level, using it.',pgvar) - level = 1; - lvlind = 1; -else - nlevs = vinfo.Size(levdim); - - fprintf('Default level (index) is %d, if this is OK, ;\n',lvlind) - fprintf('If not, enter a level between %d and %d, inclusive ...\n', ... - 1,nlevs) - varstring = input('we''ll use the closest (no syntax required)\n','s'); - - if ~isempty(varstring), lvlind = str2double(varstring); end - -% level = levels(lvlind); - level = lvlind; -end - - - -function [lon, lonind] = GetLongitude(lons, deflon) -%---------------------------------------------------------------------- -if (nargin == 2), lon = deflon; else lon = 255.0; end - -fprintf('Default longitude is %f, if this is OK, ;\n',lon) -fprintf('If not, enter a longitude between %.2f and %.2f, we use the closest.\n', ... - min(lons),max(lons)) -varstring = input('(no syntax required)\n','s'); - -if ~isempty(varstring), lon = str2double(varstring); end - -d = abs(lon - lons); % crude distance -ind = find(min(d) == d); % multiple minima possible -lonind = ind(1); % use the first one -lon = lons(lonind); - - - -function [lat, latind] = GetLatitude(lats, deflat) -%---------------------------------------------------------------------- -if (nargin == 3), lat = deflat; else lat = 40.0; end - -fprintf('Default latitude is %f, if this is OK, ;\n',lat) -fprintf('If not, enter a latitude between %.2f and %.2f, we use the closest.\n', ... - min(lats),max(lats)) -varstring = input('(no syntax required)\n','s'); - -if ~isempty(varstring), lat = str2double(varstring); end - -d = abs(lat - lats); % crude distance -ind = find(min(d) == d); % multiple minima possible -latind = ind(1); % use the first one -lat = lats(latind); - - - -function varexist(filename, varnames) -%% We already know the file exists by this point. -% Lets check to make sure that file contains all needed variables. -% Fatally die if they do not exist. - -nvars = length(varnames); -gotone = ones(1,nvars); - -for i = 1:nvars - gotone(i) = nc_isvar(filename,varnames{i}); - if ( ~ gotone(i) ) - fprintf('\n%s is not a variable in %s\n',varnames{i},filename) - end -end - -if ~ all(gotone) - error('missing required variable ... exiting') -end - Copied: DART/branches/development/matlab/GetClmInfo.m (from rev 5731, DART/branches/clm/matlab/GetClmInfo.m) =================================================================== --- DART/branches/development/matlab/GetClmInfo.m (rev 0) +++ DART/branches/development/matlab/GetClmInfo.m 2012-05-09 21:36:00 UTC (rev 5732) @@ -0,0 +1,349 @@ +function pinfo = GetClmInfo(pstruct,fname,routine) +%% GetClmInfo prepares a structure of information needed by the subsequent "routine" +% The information is gathered via rudimentary "input" routines. +% +% pinfo = GetClmInfo(pstruct,routine); +% +% pstruct structure containing the names of the truth_file and the diagn_file of the DART netcdf file +% routine name of subsequent plot routine. + +%% DART software - Copyright 2004 - 2011 UCAR. This open source software is +% provided by UCAR, "as is", without charge, subject to all terms of use at +% http://www.image.ucar.edu/DAReS/DART/DART_download +% +% +% $URL$ +% $Id$ +% $Revision$ +% $Date$ + +if (exist(fname,'file') ~= 2 ), error('%s does not exist.',fname); end + +pinfo = pstruct; +model = nc_attget(fname,nc_global,'model'); + +if strcmpi(model,'clm') ~= 1 + error('Not so fast, this is not a clm model.') +end + +%% Get the domain-independent information. + +varexist(fname, {'copy','time'}) + +copy = nc_varget(fname,'copy'); +times = nc_varget(fname,'time'); + +% Coordinate between time types and dates + +timeunits = nc_attget(fname,'time','units'); +timebase = sscanf(timeunits,'%*s%*s%d%*c%d%*c%d'); % YYYY MM DD +timeorigin = datenum(timebase(1),timebase(2),timebase(3)); +dates = times + timeorigin; + +levels = nc_varget(fname, 'levgrnd'); % coordinate soil levels (usually 15) +lon = nc_varget(fname, 'lon'); +lat = nc_varget(fname, 'lat'); + +switch lower(deblank(routine)) + + case {'plotbins','plotenserrspread','plotensmeantimeseries','plotenstimeseries'} + + base_var = GetVar(pinfo.vars, pinfo.vars{1}); % Determine prognostic variable + [level, lvlind] = GetLevel(pinfo.fname, base_var); % Determine level and index + [lat , latind] = GetLatitude(lat); + [lon , lonind] = GetLongitude(lon); + + pinfo.model = model; + pinfo.times = dates; + pinfo.var = base_var; + pinfo.level = level; + pinfo.levelindex = lvlind; + pinfo.longitude = lon; + pinfo.lonindex = lonind; + pinfo.latitude = lat; + pinfo.latindex = latind; + + case 'plotcorrel' + + disp('Getting information for the ''base'' variable.') + base_var = GetVar(pinfo.vars, pinfo.vars{1}); + [base_time, base_tmeind] = GetTime(dates); + [base_lvl, base_lvlind] = GetLevel(pinfo.fname, base_var); + [base_lat, base_latind] = GetLatitude(lat); + [base_lon, base_lonind] = GetLongitude(lon); + + disp('Getting information for the ''comparison'' variable.') + comp_var = GetVar(pinfo.vars, base_var); + [comp_lvl, comp_lvlind] = GetLevel(pinfo.fname, comp_var, base_lvlind); + + pinfo.model = model; + pinfo.times = dates; + pinfo.base_var = base_var; + pinfo.comp_var = comp_var; + pinfo.base_time = base_time; + pinfo.base_tmeind = base_tmeind; + pinfo.base_lvl = base_lvl; + pinfo.base_lvlind = base_lvlind; + pinfo.base_lat = base_lat; + pinfo.base_latind = base_latind; + pinfo.base_lon = base_lon; + pinfo.base_lonind = base_lonind; + pinfo.comp_lvl = comp_lvl; + pinfo.comp_lvlind = comp_lvlind; + + case 'plotvarvarcorrel' + + disp('Getting information for the ''base'' variable.') + base_var = GetVar(pinfo.vars, pinfo.vars{1}); + [base_time, base_tmeind] = GetTime(dates); + [base_lvl , base_lvlind] = GetLevel(pinfo.fname, base_var); + [base_lat , base_latind] = GetLatitude(lat); + [base_lon , base_lonind] = GetLongitude(lon); + + disp('Getting information for the ''comparison'' variable.') + comp_var = GetVar(pinfo.vars, base_var); + [comp_lvl, comp_lvlind] = GetLevel(pinfo.fname, comp_var, base_lvlind); + [comp_lat, comp_latind] = GetLatitude( lat, base_lat); + [comp_lon, comp_lonind] = GetLongitude(lon, base_lon); + + pinfo.model = model; + pinfo.times = dates; + pinfo.base_var = base_var; + pinfo.comp_var = comp_var; + pinfo.base_time = base_time; + pinfo.base_tmeind = base_tmeind; + pinfo.base_lvl = base_lvl; + pinfo.base_lvlind = base_lvlind; + pinfo.base_lat = base_lat; + pinfo.base_latind = base_latind; + pinfo.base_lon = base_lon; + pinfo.base_lonind = base_lonind; + pinfo.comp_lvl = comp_lvl; + pinfo.comp_lvlind = comp_lvlind; + pinfo.comp_lat = comp_lat; + pinfo.comp_latind = comp_latind; + pinfo.comp_lon = comp_lon; + pinfo.comp_lonind = comp_lonind; + + + case 'plotsawtooth' + + pgvar = GetVar(pinfo.vars, pinfo.vars{1}); + [level, lvlind] = GetLevel(pinfo.fname, pgvar); + [ lat, latind] = GetLatitude( lat); + [ lon, lonind] = GetLongitude(lon); + % [ lon, lonind] = GetCopies(pgvar,xxx); + + pinfo.model = model; + pinfo.times = dates; + pinfo.var_names = pgvar; + pinfo.truth_file = []; + pinfo.prior_file = pstruct.prior_file; + pinfo.posterior_file = pstruct.posterior_file; + pinfo.level = level; + pinfo.levelindex = lvlind; + pinfo.latitude = lat; + pinfo.latindex = latind; + pinfo.longitude = lon; + pinfo.lonindex = lonind; + pinfo.copies = 0; + pinfo.copyindices = []; + + if ( exist(pstruct.truth_file,'file') ) + pinfo.truth_file = pstruct.truth_file; + end + + + case 'plotphasespace' + + disp('Getting information for the ''X'' variable.') + var1 = GetVar(pinfo.vars, pinfo.vars{1}); + [var1_lvl, var1_lvlind] = GetLevel(pinfo.fname, var1); + [var1_lat, var1_latind] = GetLatitude( lat ); + [var1_lon, var1_lonind] = GetLongitude(lon ); + + disp('Getting information for the ''Y'' variable.') + var2 = GetVar(pinfo.fname, pinfo.vars, var1 ); + [var2_lvl, var2_lvlind] = GetLevel(pinfo.fname, var2, var1_lvlind); + [var2_lat, var2_latind] = GetLatitude( lat, var1_lat); + [var2_lon, var2_lonind] = GetLongitude(lon, var1_lon); + + disp('Getting information for the ''Z'' variable.') + var3 = GetVar(pinfo.fname, pinfo.vars, var1 ); + [var3_lvl, var3_lvlind] = GetLevel(pinfo.fname, var3, var1_lvlind); + [var3_lat, var3_latind] = GetLatitude( lat, var1_lat); + [var3_lon, var3_lonind] = GetLongitude(lon, var1_lon); + + % query for ensemble member + s1 = input('Input ensemble member metadata STRING. for ''true state'' ','s'); + if isempty(s1), ens_mem = 'true state'; else ens_mem = s1; end + + % query for line type + s1 = input('Input line type string. for ''k-'' ','s'); + if isempty(s1), ltype = 'k-'; else ltype = s1; end + + pinfo.model = model; + pinfo.times = dates; + pinfo.var1name = var1; + pinfo.var2name = var2; + pinfo.var3name = var3; + pinfo.var1_lvl = var1_lvl; + pinfo.var1_lvlind = var1_lvlind; + pinfo.var1_lat = var1_lat; + pinfo.var1_latind = var1_latind; + pinfo.var1_lon = var1_lon; + pinfo.var1_lonind = var1_lonind; + pinfo.var2_lvl = var2_lvl; + pinfo.var2_lvlind = var2_lvlind; + pinfo.var2_lat = var2_lat; + pinfo.var2_latind = var2_latind; + pinfo.var2_lon = var2_lon; + pinfo.var2_lonind = var2_lonind; + pinfo.var3_lvl = var3_lvl; + pinfo.var3_lvlind = var3_lvlind; + pinfo.var3_lat = var3_lat; + pinfo.var3_latind = var3_latind; + pinfo.var3_lon = var3_lon; + pinfo.var3_lonind = var3_lonind; + pinfo.ens_mem = ens_mem; + pinfo.ltype = ltype; + + otherwise + +end + + +function pgvar = GetVar(prognostic_vars, pgvar) +%---------------------------------------------------------------------- + +str = sprintf(' %s ',prognostic_vars{1}); +for i = 2:length(prognostic_vars), + str = sprintf(' %s %s ',str,prognostic_vars{i}); +end +fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) +fprintf('If not, please enter one of: %s\n',str) +varstring = input('(no syntax required)\n','s'); + +if ~isempty(varstring), pgvar = strtrim(varstring); end +inds = strfind(pgvar,','); +pgvar(inds) = ''; + + + +function [time, timeind] = GetTime(times, deftime) +%---------------------------------------------------------------------- +% Query for the time of interest. + +ntimes = length(times); + +% Determine a sensible default. +if (nargin == 2), + time = deftime; + tindex = find(times == deftime); +else + if (ntimes < 2) + tindex = round(ntimes/2); + else + tindex = 1; + end + time = times(tindex); +end + +fprintf('Default time is %s (index %d), if this is OK, ;\n',datestr(time),tindex) +fprintf('If not, enter an index between %d and %d \n',1,ntimes) +fprintf('Pertaining to %s and %s \n',datestr(times(1)),datestr(times(ntimes))) +varstring = input('(no syntax required)\n','s'); + +if ~isempty(varstring), tindex = str2double(varstring); end + +timeinds = 1:ntimes; +d = abs(tindex - timeinds); % crude distance +ind = find(min(d) == d); % multiple minima possible +timeind = ind(1); % use the first one +time = times(timeind); + + + +function [level, lvlind] = GetLevel(fname, pgvar, deflevel) +%---------------------------------------------------------------------- +% level and lvlind will not be equal for all models, (and probably +% shouldn't for clm ... but for future expansion ... +if (nargin == 3), lvlind = deflevel; else lvlind = 1; end + +vinfo = nc_getvarinfo(fname,pgvar); +levdim = find(strncmpi(vinfo.Dimension,'lev',3)); +if ( isempty(levdim) ) + fprintf('''%s'' only has one level, using it.',pgvar) + level = 1; + lvlind = 1; +else + nlevs = vinfo.Size(levdim); + + fprintf('Default level (index) is %d, if this is OK, ;\n',lvlind) + fprintf('If not, enter a level between %d and %d, inclusive ...\n', ... + 1,nlevs) + varstring = input('we''ll use the closest (no syntax required)\n','s'); + + if ~isempty(varstring), lvlind = str2double(varstring); end + +% level = levels(lvlind); + level = lvlind; +end + + + +function [lon, lonind] = GetLongitude(lons, deflon) +%---------------------------------------------------------------------- +if (nargin == 2), lon = deflon; else lon = 255.0; end + +fprintf('Default longitude is %f, if this is OK, ;\n',lon) +fprintf('If not, enter a longitude between %.2f and %.2f, we use the closest.\n', ... + min(lons),max(lons)) +varstring = input('(no syntax required)\n','s'); + +if ~isempty(varstring), lon = str2double(varstring); end + +d = abs(lon - lons); % crude distance +ind = find(min(d) == d); % multiple minima possible +lonind = ind(1); % use the first one +lon = lons(lonind); + + + +function [lat, latind] = GetLatitude(lats, deflat) +%---------------------------------------------------------------------- +if (nargin == 3), lat = deflat; else lat = 40.0; end + +fprintf('Default latitude is %f, if this is OK, ;\n',lat) +fprintf('If not, enter a latitude between %.2f and %.2f, we use the closest.\n', ... + min(lats),max(lats)) +varstring = input('(no syntax required)\n','s'); + +if ~isempty(varstring), lat = str2double(varstring); end + +d = abs(lat - lats); % crude distance +ind = find(min(d) == d); % multiple minima possible +latind = ind(1); % use the first one +lat = lats(latind); + + + +function varexist(filename, varnames) +%% We already know the file exists by this point. +% Lets check to make sure that file contains all needed variables. +% Fatally die if they do not exist. + +nvars = length(varnames); +gotone = ones(1,nvars); + +for i = 1:nvars + gotone(i) = nc_isvar(filename,varnames{i}); + if ( ~ gotone(i) ) + fprintf('\n%s is not a variable in %s\n',varnames{i},filename) + end +end + +if ~ all(gotone) + error('missing required variable ... exiting') +end + Property changes on: DART/branches/development/matlab/GetClmInfo.m ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Rev Author HeadURL Id Added: svn:mergeinfo + /DART/trunk/matlab/GetClmInfo.m:5026-5730 Added: svn:eol-style + native From nancy at ucar.edu Wed May 9 16:05:38 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 16:05:38 -0600 Subject: [Dart-dev] [5733] DART/branches/development/matlab: Adding partial support for CLM. Message-ID: Revision: 5733 Author: thoar Date: 2012-05-09 16:05:37 -0600 (Wed, 09 May 2012) Log Message: ----------- Adding partial support for CLM. There are many more functions that need to be implemented. Modified Paths: -------------- DART/branches/development/matlab/CheckModel.m DART/branches/development/matlab/GetNCindices.m DART/branches/development/matlab/PlotCorrel.m DART/branches/development/matlab/plot_bins.m DART/branches/development/matlab/plot_correl.m -------------- next part -------------- Modified: DART/branches/development/matlab/CheckModel.m =================================================================== --- DART/branches/development/matlab/CheckModel.m 2012-05-09 21:36:00 UTC (rev 5732) +++ DART/branches/development/matlab/CheckModel.m 2012-05-09 22:05:37 UTC (rev 5733) @@ -1,11 +1,11 @@ function vars = CheckModel(fname) -%% CheckModel tries to ensure that a netcdf file has what we expect. +%% CheckModel tries to ensure that a netcdf file has what we expect. % % vars is a structure containing a minimal amount of metadata about the netCDF file. -% +% % EXAMPLE: % fname = 'Prior_Diag.nc'; -% vars = CheckModel(fname) +% vars = CheckModel(fname) %% DART software - Copyright 2004 - 2011 UCAR. This open source software is % provided by UCAR, "as is", without charge, subject to all terms of use at @@ -32,7 +32,7 @@ clear times timeunits timebase timeorigin -if (isempty(model)) +if (isempty(model)) error('%s has no ''model'' global attribute.',fname) end @@ -43,7 +43,7 @@ num_vars = dim_length(fname,'StateVariable'); % determine # of state varbls StateVariable = nc_varget(fname,'StateVariable'); - def_state_vars = zeros(1,num_vars); % for use as a subscript array, + def_state_vars = zeros(1,num_vars); % for use as a subscript array, def_state_vars(:) = StateVariable(:); % def_state_vars must be a row vector. vars = struct('model',model, ... @@ -65,7 +65,7 @@ num_vars = dim_length(fname,'StateVariable'); % determine # of state varbls StateVariable = nc_varget(fname,'StateVariable'); - % The only trick is to pick an equally-spaced subset of state + % The only trick is to pick an equally-spaced subset of state % variables for the default. def_state_vars = round([1 , num_vars/3 , 2*num_vars/3]); @@ -96,7 +96,7 @@ num_vars = dim_length(fname,'StateVariable'); % determine # of state varbls - % The only trick is to pick an equally-spaced subset of state + % The only trick is to pick an equally-spaced subset of state % variables for the default. def_state_vars = round([1 , num_model_vars/3 , 2*num_model_vars/3]); @@ -132,7 +132,7 @@ num_Y = dim_length(fname,'Ydim'); % # of Y variables Ydim = nc_varget(fname,'Ydim'); - % The only trick is to pick an equally-spaced subset of state + % The only trick is to pick an equally-spaced subset of state % variables for the default. def_X_inds = round([1 , num_X/3 , 2*num_X/3]); @@ -209,7 +209,24 @@ vars.vars = varnames; vars.fname = fname; - + + case {'clm'} + + varnames = get_DARTvars(fname); + num_vars = length(varnames); + dinfo = nc_getdiminfo(fname,'levtot'); + nlevels = dinfo.Length; + + vars = struct('model',model, ... + 'num_state_vars',num_vars, ... + 'num_ens_members',num_copies, ... + 'time_series_length',num_times, ... + 'min_ens_mem',min(copy), ... + 'max_ens_mem',max(copy) ); + + vars.vars = varnames; + vars.fname = fname; + case {'cam','tiegcm','fms_bgrid','pe2lyr','mitgcm_ocean','pbl_1d','mpas_atm'} varnames = get_DARTvars(fname); @@ -227,7 +244,7 @@ vars.vars = varnames; vars.fname = fname; - + otherwise error('model %s unknown',model) @@ -237,7 +254,7 @@ function x = dim_length(fname,dimname) % Check for the existence of the named dimension and return it -% if it exists. If it does not, error out with a useful message. +% if it exists. If it does not, error out with a useful message. info = nc_info(fname); n = length(dimname); Modified: DART/branches/development/matlab/GetNCindices.m =================================================================== --- DART/branches/development/matlab/GetNCindices.m 2012-05-09 21:36:00 UTC (rev 5732) +++ DART/branches/development/matlab/GetNCindices.m 2012-05-09 22:05:37 UTC (rev 5733) @@ -17,7 +17,7 @@ % pinfo.stateindex % pinfo.regionindex % -% whichfile is a character string specifying which +% whichfile is a character string specifying which % filename component of 'pinfo' will be used. % ['prior','posterior','truth','diagn','fname'] % varname is the netcdf variable being extracted. @@ -127,11 +127,11 @@ start = zeros(1,ndims); count = zeros(1,ndims); -% varinfo.Dimension is a cell array of the Dimension strings +% varinfo.Dimension is a cell array of the Dimension strings % varinfo.Size is an N-D array describing the variable shape % varinfo.Attribute is a struct holding the variable attribues -% loop over all of the variables dimensions and +% loop over all of the variables dimensions and % build up the start/endpoint arrays for i = 1:ndims @@ -146,10 +146,10 @@ % ditto for lat, lon ... (on staggered grids, for example) % So the XG coordinate dimension has 'cartesian_axis = X', % for example. - + [len, status, value] = is_dimension_cartesian(fname, diminfo.Name); - - if (status > 0) + + if (status > 0) dimname = value; else % Then there is no 'cartesian_axis' attribute and the best we can @@ -164,7 +164,7 @@ case 'copy' start(i) = copy1; count(i) = copyN; - case {'surf','unde','hlev','mlev','plev','heig','leve','bott','ilev','nver'} + case {'surf','unde','hlev','mlev','plev','heig','leve','bott','ilev','nver','levt','levs'} start(i) = level1; count(i) = levelN; case {'tmpj','sout'} @@ -218,9 +218,9 @@ value = []; if ( nc_isvar(fname,dimname) ) - + % Good - the coordinate variable exists. - + Cvarinfo = nc_getvarinfo(fname, dimname); for j = 1:length(Cvarinfo.Attribute); @@ -236,6 +236,6 @@ end else % there is no coordinate variable ... use something else - + end Modified: DART/branches/development/matlab/PlotCorrel.m =================================================================== --- DART/branches/development/matlab/PlotCorrel.m 2012-05-09 21:36:00 UTC (rev 5732) +++ DART/branches/development/matlab/PlotCorrel.m 2012-05-09 22:05:37 UTC (rev 5733) @@ -62,7 +62,7 @@ state_var = get_hyperslab('fname',pinfo.fname, 'varname',pinfo.base_var, ... 'copyindex1',pinfo.ensemble_indices(1),'copycount',pinfo.num_ens_members, ... 'state1',pinfo.min_state_var,'statecount',pinfo.num_state_vars); - + % It is efficient to preallocate correl storage ... correl = zeros(pinfo.num_state_vars,pinfo.time_series_length); @@ -359,7 +359,7 @@ axis image colorbar; - case {'tiegcm'} + case 'tiegcm' % We are going to correlate one var/time/lvl/lat/lon with % all other lats/lons for a var/time/lvl @@ -415,7 +415,7 @@ axis image colorbar; - case {'mpas_atm'} + case 'mpas_atm' %% We are going to correlate one var/time/lvl/location with % all other locations for a var/time/lvl @@ -462,6 +462,72 @@ axis([-10 370 -Inf Inf]) colorbar; + case 'clm' + + % We are going to correlate one var/time/lvl/lat/lon with + % all other lats/lons for a var/time/lvl + + clf; + + lats = nc_varget(pinfo.fname,'lat'); ny = length(lats); + lons = nc_varget(pinfo.fname,'lon'); nx = length(lons); + latunits = nc_attget(pinfo.fname,'lat','units'); + lonunits = nc_attget(pinfo.fname,'lon','units'); + + nxny = nx*ny; + + %% CLM variables must be reconstituted into grid cell values for + % each ensemble member. + % Need all copies ... base_mem has shape [1,nmembers] + % Need all copies ... comp_ens has shape [nmembers,nxny] + + metadata = nc_varget(pinfo.fname,'CopyMetaData'); % get all the metadata + copyindices = strmatch('ensemble member',metadata); % find all 'member's + nmembers = length(copyindices); + + base_mem = zeros(1,nmembers); + comp_ens = zeros(nmembers,nxny); + corr = zeros(nxny,1); + + for imem = 1:nmembers, + + copystring = sprintf('ensemble member %d',imem); + base = clm_get_var(pinfo.fname, pinfo.base_var, copystring, ... + pinfo.base_lvlind, pinfo.base_tmeind); + base_mem(imem) = base.datmat(pinfo.base_latind, pinfo.base_lonind); + + comp = clm_get_var(pinfo.fname, pinfo.comp_var, copystring, ... + pinfo.comp_lvlind, pinfo.base_tmeind); + comp_ens(imem,:) = comp.datmat(:); + + end + + for i = 1:nxny, + x = corrcoef(base_mem, comp_ens(:, i)); + corr(i) = x(1, 2); + end + + correl = reshape(corr,[ny nx]); + +% contour(lons,lats,correl,[-1:0.2:-0.2 0.2:0.2:1.0]); hold on; + h3 = imagesc(lons,lats,correl); set(gca,'YDir','normal'); + set(h3,'AlphaData',~isnan(correl)) + hold on; + plot(pinfo.base_lon, pinfo.base_lat, 'pk', ... + 'MarkerSize',12,'MarkerFaceColor','k'); + s1 = sprintf('%s Correlation of ''%s'', level %d, (%.2f,%.2f) T = %f', ... + model, pinfo.base_var, pinfo.base_lvl, ... + pinfo.base_lat, pinfo.base_lon, pinfo.base_time); + + s2 = sprintf('against ''%s'', entire level %d, same time, %d ensemble members', ... + pinfo.comp_var, pinfo.comp_lvl, nmembers); + title({s1,s2,pinfo.fname},'interpreter','none','fontweight','bold') + xlabel(sprintf('longitude (%s)',lonunits),'interpreter','none') + ylabel(sprintf('latitude (%s)',latunits),'interpreter','none') + worldmap('hollow'); + axis image + h = colorbar; + otherwise error('model %s not implemented yet', pinfo.model) Modified: DART/branches/development/matlab/plot_bins.m =================================================================== --- DART/branches/development/matlab/plot_bins.m 2012-05-09 21:36:00 UTC (rev 5732) +++ DART/branches/development/matlab/plot_bins.m 2012-05-09 22:05:37 UTC (rev 5733) @@ -1,4 +1,4 @@ -%% DART:plot_bins Plots ensemble rank histograms +%% DART:plot_bins Plots ensemble rank histograms % % plot_bins interactively queries for the information needed to create % ensemble rank histograms. Since different models potentially @@ -24,12 +24,12 @@ % $Revision$ % $Date$ -% error_checking ... -% exist('bob') == 1 means the variable exists. +% error_checking ... +% exist('bob') == 1 means the variable exists. % the value of the variable is checked later. -if (exist('truth_file','var') ~= 1) - disp('Input name of True State file:') +if (exist('truth_file','var') ~= 1) + disp('Input name of True State file:') truth_file = input(' for True_State.nc\n','s'); if isempty(truth_file) truth_file = 'True_State.nc'; @@ -37,7 +37,7 @@ end if (exist('diagn_file','var') ~=1) - disp('Input name of prior or posterior diagnostics file:') + disp('Input name of prior or posterior diagnostics file:') diagn_file = input(' for Prior_Diag.nc\n','s'); if isempty(diagn_file) diagn_file = 'Prior_Diag.nc'; @@ -71,6 +71,10 @@ pinfo = GetCamInfo(pinfo, diagn_file, 'PlotBins'); + case 'clm' + + pinfo = GetClmInfo(pinfo, diagn_file, 'PlotBins'); + case 'wrf' pinfo = GetWRFInfo(pinfo, diagn_file, 'PlotBins'); @@ -84,7 +88,7 @@ pinfo = GetMITgcm_oceanInfo(pinfo, diagn_file, 'PlotBins'); case 'mpas_atm' - + pinfo = GetMPAS_ATMInfo(pinfo, diagn_file, 'PlotBins'); otherwise Modified: DART/branches/development/matlab/plot_correl.m =================================================================== --- DART/branches/development/matlab/plot_correl.m 2012-05-09 21:36:00 UTC (rev 5732) +++ DART/branches/development/matlab/plot_correl.m 2012-05-09 22:05:37 UTC (rev 5733) @@ -1,11 +1,11 @@ -%% DART:plot_correl Plots space-time series of correlation between a given variable -% at a given time and other variables at all times in an +%% DART:plot_correl Plots space-time series of correlation between a given variable +% at a given time and other variables at all times in an % ensemble time sequence. % % plot_correl interactively queries for the information needed to create % the desired correlations. -% Since different models potentially need different pieces -% of information ... the model types are determined and +% Since different models potentially need different pieces +% of information ... the model types are determined and % additional user input may be queried. %% DART software - Copyright 2004 - 2011 UCAR. This open source software is @@ -24,7 +24,7 @@ if isempty(diagn_file) diagn_file = 'Prior_Diag.nc'; end -end +end if ( exist(diagn_file,'file') ~= 2 ), error('%s does not exist.',diagn_file); end @@ -103,6 +103,10 @@ pinfo = GetCamInfo(pinfo, diagn_file, 'PlotCorrel'); + case 'clm' + + pinfo = GetClmInfo(pinfo, diagn_file, 'PlotCorrel'); + case 'wrf' pinfo = GetWRFInfo(pinfo, diagn_file, 'PlotCorrel'); From nancy at ucar.edu Wed May 9 16:06:41 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 16:06:41 -0600 Subject: [Dart-dev] [5734] DART/branches/development/matlab: Whitespace changes only. Message-ID: Revision: 5734 Author: thoar Date: 2012-05-09 16:06:41 -0600 (Wed, 09 May 2012) Log Message: ----------- Whitespace changes only. No user-visible changes. Modified Paths: -------------- DART/branches/development/matlab/BgridTotalError.m DART/branches/development/matlab/CAMTotalError.m DART/branches/development/matlab/CheckModelCompatibility.m DART/branches/development/matlab/ChecknetCDFuse.m DART/branches/development/matlab/DART.m DART/branches/development/matlab/DiffnetCDFstate.m DART/branches/development/matlab/GetBgridInfo.m DART/branches/development/matlab/GetCalendarDate.m DART/branches/development/matlab/GetCamInfo.m DART/branches/development/matlab/GetMITgcm_oceanInfo.m DART/branches/development/matlab/GetMPAS_ATMInfo.m DART/branches/development/matlab/GetPe2lyrInfo.m DART/branches/development/matlab/GetTIEGCMInfo.m DART/branches/development/matlab/GetWRFInfo.m DART/branches/development/matlab/ParseAlphaNumerics.m DART/branches/development/matlab/PlotBins.m DART/branches/development/matlab/PlotCEnsErrSpread.m DART/branches/development/matlab/PlotEnsErrSpread.m DART/branches/development/matlab/PlotEnsMeanTimeSeries.m DART/branches/development/matlab/PlotEnsTimeSeries.m DART/branches/development/matlab/PlotJeffCorrel.m DART/branches/development/matlab/PlotTotalErr.m DART/branches/development/matlab/PlotVarVarCorrel.m DART/branches/development/matlab/ReadASCIIObsSeq.m DART/branches/development/matlab/ReadBinaryObsSeq.m DART/branches/development/matlab/ReadObsSeq.m DART/branches/development/matlab/SetCopyID.m DART/branches/development/matlab/SetCopyID2.m DART/branches/development/matlab/SetVariableID.m DART/branches/development/matlab/SimpleMap.m DART/branches/development/matlab/StatObsSeq.m DART/branches/development/matlab/WRFTotalError.m DART/branches/development/matlab/get_DARTvars.m DART/branches/development/matlab/get_copy_index.m DART/branches/development/matlab/get_ens_size.m DART/branches/development/matlab/get_qc_index.m DART/branches/development/matlab/get_var_series.m DART/branches/development/matlab/locations_in_region.m DART/branches/development/matlab/parse.m DART/branches/development/matlab/plot_ens_err_spread.m DART/branches/development/matlab/plot_ens_mean_time_series.m DART/branches/development/matlab/plot_ens_time_series.m DART/branches/development/matlab/plot_jeff_correl.m DART/branches/development/matlab/plot_phase_space.m DART/branches/development/matlab/plot_reg_factor.m DART/branches/development/matlab/plot_smoother_err.m DART/branches/development/matlab/plot_total_err.m DART/branches/development/matlab/plot_var_var_correl.m DART/branches/development/matlab/read_state.m DART/branches/development/matlab/scalebar.m DART/branches/development/matlab/startup.m DART/branches/development/matlab/worldmap.m -------------- next part -------------- Modified: DART/branches/development/matlab/BgridTotalError.m =================================================================== --- DART/branches/development/matlab/BgridTotalError.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/BgridTotalError.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -26,7 +26,7 @@ for ivar=1:pinfo.num_state_vars, fprintf('Processing %s ...\n', pinfo.vars{ivar} ) - + rmse = zeros(pinfo.time_series_length,1); sprd = zeros(pinfo.time_series_length,1); varunits = nc_attget(pinfo.truth_file, pinfo.vars{ivar}, 'units'); @@ -47,7 +47,7 @@ case {'tmpi', 'veli'} longitudes = nc_varget(pinfo.diagn_file, dimname); case {'lev'} - nlevels = dimlength; + nlevels = dimlength; end end @@ -55,7 +55,7 @@ weights = SphereWeights(latitudes, longitudes); for itime=1:pinfo.time_series_length, - + truth = get_hyperslab('fname',pinfo.truth_file, 'varname',pinfo.vars{ivar}, ... 'copyindex',truth_index, 'timeindex',pinfo.truth_time(1)+itime-1); ens = get_hyperslab('fname',pinfo.diagn_file, 'varname',pinfo.vars{ivar}, ... @@ -82,7 +82,7 @@ %% Take the square root of the mean squared error rmse(itime) = sqrt(ms_err); sprd(itime) = sqrt(ms_spread); - + end % loop over time %------------------------------------------------------------------- @@ -101,7 +101,7 @@ s1 = sprintf('%s %s Ensemble Mean', pinfo.model,pinfo.vars{ivar}); title({s1,pinfo.diagn_file},'interpreter','none','fontweight','bold') -end % loop around variables +end % loop around variables clear truth ens spread err XY_spread Modified: DART/branches/development/matlab/CAMTotalError.m =================================================================== --- DART/branches/development/matlab/CAMTotalError.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/CAMTotalError.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -42,17 +42,17 @@ sprd = zeros(pinfo.time_series_length,1); for itime=1:pinfo.time_series_length, - + fprintf('Processing %s timestep %d of %d ...\n', ... varname, itime, pinfo.time_series_length) - + truth = get_hyperslab('fname',pinfo.truth_file, 'varname',varname, ... 'copyindex',truth_index, 'timeindex',pinfo.truth_time(1)+itime-1); ens = get_hyperslab('fname',pinfo.diagn_file, 'varname',varname, ... 'copyindex',ens_mean_index, 'timeindex',pinfo.diagn_time(1)+itime-1); spread = get_hyperslab('fname',pinfo.diagn_file, 'varname',varname, ... 'copyindex',ens_spread_index, 'timeindex',pinfo.diagn_time(1)+itime-1); - + if (length(size(truth)) == 2) nlev = 1; elseif (length(size(truth)) == 3) @@ -65,7 +65,7 @@ msqe_Z = zeros(nlev,1); sprd_Z = zeros(nlev,1); - + for ilevel=1:nlev, slabS2E = (truth(:,:,ilevel) - ens(:,:,ilevel)).^2; % OK even if 2D iff ilevel = 1 @@ -76,12 +76,12 @@ msqe_Z(ilevel) = XY_err; sprd_Z(ilevel) = XY_spread; - end % loop over levels + end % loop over levels %% Take the square root of the mean of all levels rmse(itime) = sqrt(mean(msqe_Z)); sprd(itime) = sqrt(mean(sprd_Z)); - + end % loop over time %------------------------------------------------------------------- @@ -102,7 +102,7 @@ s1 = sprintf('%s %s Ensemble Mean', pinfo.model,pinfo.vars{ivar}); title({s1,pinfo.diagn_file},'interpreter','none','fontweight','bold') -end % loop around variables +end % loop around variables clear truth ens spread err XY_spread Modified: DART/branches/development/matlab/CheckModelCompatibility.m =================================================================== --- DART/branches/development/matlab/CheckModelCompatibility.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/CheckModelCompatibility.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -4,9 +4,9 @@ % pinfo struct (with 2 filenames and 2 2-vector arrays for start/stop times). % This routine fills in the 2-vectors with the time overlap region in a % pinfo struct. -% If the time indices are common between the 2 files it returns the +% If the time indices are common between the 2 files it returns the % [start,count] indices for each array (indexing starts at 1,N). -% It is an error situation if there is no overlap ([-1,-1] for both). +% It is an error situation if there is no overlap ([-1,-1] for both). %% DART software - Copyright 2004 - 2011 UCAR. This open source software is % provided by UCAR, "as is", without charge, subject to all terms of use at @@ -41,7 +41,7 @@ %% Get some information from the file1 tmodel = nc_attget(file1,nc_global,'model'); -if (isempty(tmodel)) +if (isempty(tmodel)) error('%s has no ''model'' global attribute.',file1) end @@ -61,7 +61,7 @@ %% Get some information from the file2 dmodel = nc_attget(file1,nc_global,'model'); -if (isempty(dmodel)) +if (isempty(dmodel)) error('%s has no ''model'' global attribute.',file2) end @@ -185,15 +185,15 @@ if (abs(maxA - minB) < epsilon) , minB = maxA; end if (abs(maxA - maxB) < epsilon) , maxB = maxA; end -%% case 1: disjoint regions; simply return here because +%% case 1: disjoint regions; simply return here because % return struct was initialized to the 'no intersection' case. -if ((minA < minB) && (maxA < minB)) +if ((minA < minB) && (maxA < minB)) return end %% case 2: B fully contained in A; return corresponding index nums of overlap % include equal start & end points in this case. -if ((minA <= minB) && (maxB <= maxA)) +if ((minA <= minB) && (maxB <= maxA)) minI = find(abs(A - minB) < epsilon); maxI = find(abs(A - maxB) < epsilon); minJ = 1; @@ -230,7 +230,7 @@ function x = dim_length(fname,dimname) %% Check for the existence of the named dimension and return it -% if it exists. If it does not, error out with a useful message. +% if it exists. If it does not, error out with a useful message. info = nc_info(fname); n = length(dimname); @@ -242,7 +242,7 @@ end end -if isempty(x) +if isempty(x) error('%s has no dimension named %s',fname,dimname) end Modified: DART/branches/development/matlab/ChecknetCDFuse.m =================================================================== --- DART/branches/development/matlab/ChecknetCDFuse.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/ChecknetCDFuse.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -1,6 +1,6 @@ function x = ChecknetCDFuse(fname) -%% ChecknetCDFuse checks to see if the netcdf pieces are available. -% +%% ChecknetCDFuse checks to see if the netcdf pieces are available. +% % x = ChecknetCDFuse(fname); % % fname ... a filename that contains diagnostic information. Modified: DART/branches/development/matlab/DART.m =================================================================== --- DART/branches/development/matlab/DART.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/DART.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -1,12 +1,12 @@ -%% DART - the list of routines useful for exploring the output of the DART +%% DART - the list of routines useful for exploring the output of the DART % ensemble assimilation software. This is not intended to be an exhaustive % list, but it should get you started. -- Tim -% +% % $Id$ -% +% % DART/matlab These functions explore the [Truth,] Prior,Posterior netCDF % files. Useful for "state-space" diagnostics. -% plot_bins.m rank histograms +% plot_bins.m rank histograms % plot_correl.m space-time series of correlation % plot_ens_err_spread.m summary plots of the ensemble error and ensemble spread % plot_ens_mean_time_series.m time series of ensemble mean and truth @@ -16,36 +16,36 @@ % plot_smoother_err.m global error and spread using the smoother % plot_total_err.m plots of global error and spread of ensemble mean % plot_var_var_correl.m correlation of a vrbl at a time and another vrbl at all times -% -% +% +% % DART/diagnostics/matlab This block requires that the observation sequences in % question have been run through "obs_diag" and have % resulted in "obs_diag_output.nc" files. Strictly % "observation-space" diagnostics. Typical quantities of % interest are : rmse, bias, spread, totalspread, ... -% plot_observation_locations.m locations of observations, by QC value +% plot_observation_locations.m locations of observations, by QC value % plot_profile.m vertical profile of a single quantity % plot_bias_xxx_profile.m vertical profile of the bias and any other quantity % plot_rmse_xxx_profile.m vertical profile of the rmse and any other quantity % plot_evolution.m temporal evolution of any quantity % plot_rmse_xxx_evolution.m temporal evolution of the rmse and one other quantity -% plot_wind_vectors.m This is a "one-off" ... since DART actually only knows -% about univariate observations, matching them into pairs +% plot_wind_vectors.m This is a "one-off" ... since DART actually only knows +% about univariate observations, matching them into pairs % is perilous ... -% -% -% DART/diagnostics/matlab These functions require processing -% observation sequences into netCDF files with +% +% +% DART/diagnostics/matlab These functions require processing +% observation sequences into netCDF files with % "obs_seq_to_netcdf" - which currently does not preserve % all of the observation sequence metadata for some of the -% more complicated observation types. +% more complicated observation types. % read_obs_netcdf.m Reads a netCDF observation sequence and returns a structure. -% plot_obs_netcdf.m creates a 2D or 3D plot of the observation locations +% plot_obs_netcdf.m creates a 2D or 3D plot of the observation locations % and values - and rejected observations. % plot_obs_netcdf_diffs.m ditto, only for the difference of two observation copies % - the observation and the ensemble mean, for example. -% -% +% +% % DART/models//matlab Each model has an optional matlab directory where % the model developers are free to supply whatever functions % or scripts they deem useful. Modified: DART/branches/development/matlab/DiffnetCDFstate.m =================================================================== --- DART/branches/development/matlab/DiffnetCDFstate.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/DiffnetCDFstate.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -1,6 +1,6 @@ function DiffnetCDFstate(file1,file2,outfile) -%% DiffnetCDFstate checks to see if the netcdf pieces are available. -% +%% DiffnetCDFstate checks to see if the netcdf pieces are available. +% % DiffnetCDFstate(nc1, nc2, outfile); % % fname ... a filename that contains diagnostic information. @@ -57,7 +57,7 @@ a = min(c); b = max(c); -clear c +clear c % Write the min and max of the differences to a file Modified: DART/branches/development/matlab/GetBgridInfo.m =================================================================== --- DART/branches/development/matlab/GetBgridInfo.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/GetBgridInfo.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -205,11 +205,11 @@ for i = 2:length(prognostic_vars), str = sprintf(' %s %s ',str,prognostic_vars{i}); end -fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) +fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) fprintf('If not, please enter one of: %s\n',str) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), pgvar = deblank(varstring); end +if ~isempty(varstring), pgvar = deblank(varstring); end @@ -222,10 +222,10 @@ min(times),max(times)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), time = str2num(varstring); end +if ~isempty(varstring), time = str2num(varstring); end d = abs(time - times); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible timeind = ind(1); % use the first one time = times(timeind); @@ -236,7 +236,7 @@ % shouldn't for the bgrid ... but for future expansion ... if (nargin == 3), level = deflevel; else level = 1; end -if strcmp(pgvar,'ps') ==1 +if strcmp(pgvar,'ps') ==1 disp('''ps'' only has one level, using it.') level = 1; lvlind = 1; @@ -246,10 +246,10 @@ min(levels),max(levels)) varstring = input('we''ll use the closest (no syntax required)\n','s'); - if ~isempty(varstring), level = str2num(varstring); end + if ~isempty(varstring), level = str2num(varstring); end d = abs(level - levels); % crude distance - ind = find(min(d) == d); % multiple minima possible + ind = find(min(d) == d); % multiple minima possible lvlind = ind(1); % use the first one level = levels(lvlind); end @@ -267,15 +267,15 @@ lons = VelI; end -fprintf('Default longitude is %f, if this is OK, ;\n',lon) +fprintf('Default longitude is %f, if this is OK, ;\n',lon) fprintf('If not, enter a longitude between %.2f and %.2f, we use the closest.\n', ... min(lons),max(lons)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), lon = str2num(varstring); end +if ~isempty(varstring), lon = str2num(varstring); end d = abs(lon - lons); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible lonind = ind(1); % use the first one lon = lons(lonind); @@ -297,10 +297,10 @@ min(lats),max(lats)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), lat = str2num(varstring); end +if ~isempty(varstring), lat = str2num(varstring); end d = abs(lat - lats); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible latind = ind(1); % use the first one lat = lats(latind); Modified: DART/branches/development/matlab/GetCalendarDate.m =================================================================== --- DART/branches/development/matlab/GetCalendarDate.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/GetCalendarDate.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -1,7 +1,7 @@ function h = GetCalendarDate(seconds,days,calendartype) %% h = GetCalendarDate(seconds,days [,calendartype] ) % -% seconds, days are the DART times +% seconds, days are the DART times % % EXAMPLE: % @@ -17,7 +17,7 @@ % $Revision$ % $Date$ -if (nargin < 2) +if (nargin < 2) error('Must supply at least two arguments, seconds and days') elseif (nargin ==2) calendartype = 'Gregorian'; Modified: DART/branches/development/matlab/GetCamInfo.m =================================================================== --- DART/branches/development/matlab/GetCamInfo.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/GetCamInfo.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -135,8 +135,8 @@ if ( exist(pstruct.truth_file,'file') ) pinfo.truth_file = pstruct.truth_file; end - + case 'plotphasespace' disp('Getting information for the ''X'' variable.') @@ -202,11 +202,11 @@ for i = 2:length(prognostic_vars), str = sprintf(' %s %s ',str,prognostic_vars{i}); end -fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) +fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) fprintf('If not, please enter one of: %s\n',str) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), pgvar = strtrim(varstring); end +if ~isempty(varstring), pgvar = strtrim(varstring); end inds = strfind(pgvar,','); pgvar(inds) = ''; @@ -240,7 +240,7 @@ timeinds = 1:ntimes; d = abs(tindex - timeinds); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible timeind = ind(1); % use the first one time = times(timeind); @@ -252,7 +252,7 @@ % shouldn't for cam ... but for future expansion ... if (nargin == 3), lvlind = deflevel; else lvlind = 1; end -if strcmpi(pgvar,'ps') ==1 +if strcmpi(pgvar,'ps') ==1 disp('''PS'' only has one level, using it.') level = 1; lvlind = 1; @@ -262,10 +262,10 @@ 1,length(levels)) varstring = input('we''ll use the closest (no syntax required)\n','s'); - if ~isempty(varstring), lvlind = str2double(varstring); end + if ~isempty(varstring), lvlind = str2double(varstring); end % d = abs(level - levels); % crude distance - % ind = find(min(d) == d); % multiple minima possible + % ind = find(min(d) == d); % multiple minima possible % lvlind = ind(1); % use the first one level = levels(lvlind); end @@ -276,15 +276,15 @@ %---------------------------------------------------------------------- if (nargin == 2), lon = deflon; else lon = 255.0; end -fprintf('Default longitude is %f, if this is OK, ;\n',lon) +fprintf('Default longitude is %f, if this is OK, ;\n',lon) fprintf('If not, enter a longitude between %.2f and %.2f, we use the closest.\n', ... min(lons),max(lons)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), lon = str2double(varstring); end +if ~isempty(varstring), lon = str2double(varstring); end d = abs(lon - lons); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible lonind = ind(1); % use the first one lon = lons(lonind); @@ -299,10 +299,10 @@ min(lats),max(lats)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), lat = str2double(varstring); end +if ~isempty(varstring), lat = str2double(varstring); end d = abs(lat - lats); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible latind = ind(1); % use the first one lat = lats(latind); Modified: DART/branches/development/matlab/GetMITgcm_oceanInfo.m =================================================================== --- DART/branches/development/matlab/GetMITgcm_oceanInfo.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/GetMITgcm_oceanInfo.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -195,11 +195,11 @@ for i = 2:length(prognostic_vars), str = sprintf(' %s %s ',str,prognostic_vars{i}); end -fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) +fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) fprintf('If not, please enter one of: %s\n',str) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), pgvar = strtrim(varstring); end +if ~isempty(varstring), pgvar = strtrim(varstring); end inds = strfind(pgvar,','); pgvar(inds) = ''; a = strread(pgvar,'%s','delimiter',' '); @@ -214,10 +214,10 @@ min(times),max(times)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), time = str2num(varstring); end +if ~isempty(varstring), time = str2num(varstring); end d = abs(time - times); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible timeind = ind(1); % use the first one time = times(timeind); @@ -232,7 +232,7 @@ lvlind = 1; end -if strcmp(lower(pgvar),'ssh') ==1 +if strcmp(lower(pgvar),'ssh') ==1 disp('''SSH'' only has one level, using it.') level = 1; lvlind = 1; @@ -242,10 +242,10 @@ 1,length(levels)) varstring = input('we''ll use the closest (no syntax required)\n','s'); - if ~isempty(varstring), lvlind = str2num(varstring); end + if ~isempty(varstring), lvlind = str2num(varstring); end % d = abs(level - levels); % crude distance - % ind = find(min(d) == d); % multiple minima possible + % ind = find(min(d) == d); % multiple minima possible % lvlind = ind(1); % use the first one level = levels(lvlind); end @@ -268,10 +268,10 @@ min(lons),max(lons)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), lon = str2num(varstring); end +if ~isempty(varstring), lon = str2num(varstring); end d = abs(lon - lons); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible lonind = ind(1); % use the first one lon = lons(lonind); @@ -293,10 +293,10 @@ min(lats),max(lats)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), lat = str2num(varstring); end +if ~isempty(varstring), lat = str2num(varstring); end d = abs(lat - lats); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible latind = ind(1); % use the first one lat = lats(latind); Modified: DART/branches/development/matlab/GetMPAS_ATMInfo.m =================================================================== --- DART/branches/development/matlab/GetMPAS_ATMInfo.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/GetMPAS_ATMInfo.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -7,7 +7,7 @@ % % pinfo_in Name of existing pinfo struct, e.g. output from CheckModelCompatibility % fname Name of the DART netcdf file - usually [Prior,Posterior]_Diag.nc -% routine name of subsequent plot routine. +% routine name of subsequent plot routine. %% DART software - Copyright 2004 - 2011 UCAR. This open source software is % provided by UCAR, "as is", without charge, subject to all terms of use at @@ -48,7 +48,7 @@ case {'plottotalerr'} pinfo.fname = fname; - + case {'plotbins','plotenserrspread','plotensmeantimeseries','plotenstimeseries'} pgvar = GetVarString(pinfo_in.vars); @@ -142,7 +142,7 @@ % So now I have to figure out if the posterior and prior copy metadata match. for i = 1:copy, - copyi = get_copy_index(pinfo_in.posterior_file,copymetadata{i}); + copyi = get_copy_index(pinfo_in.posterior_file,copymetadata{i}); pstruct.postcopyindices = copyi; end @@ -203,7 +203,7 @@ pinfo.ltype = ltype; otherwise - + error('%s unsupported for %s',routine, pinfo.model) end @@ -219,11 +219,11 @@ for i = 2:length(prognostic_vars), str = sprintf(' %s %s ',str,prognostic_vars{i}); end -fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) +fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) fprintf('If not, please enter one of: %s\n',str) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), pgvar = deblank(varstring); end +if ~isempty(varstring), pgvar = deblank(varstring); end @@ -238,7 +238,7 @@ time = deftime; tindex = find(times == deftime); else - if (ntimes < 2) + if (ntimes < 2) tindex = round(ntimes/2); else tindex = 1; @@ -251,11 +251,11 @@ fprintf('Pertaining to %s and %s \n',datestr(times(1)),datestr(times(ntimes))) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), tindex = str2num(varstring); end +if ~isempty(varstring), tindex = str2num(varstring); end timeinds = 1:ntimes; d = abs(tindex - timeinds); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible timeind = ind(1); % use the first one time = times(timeind); @@ -282,7 +282,7 @@ lvlind = 1; else - + nlevels = varinfo.Size(vertdim); levels = 1:nlevels; if (nargin == 3) @@ -295,10 +295,10 @@ fprintf('If not, enter a level index between 1 and %d, inclusive ...\n',nlevels) varstring = input('we''ll use the closest (no syntax required)\n','s'); - if ~isempty(varstring), level = str2num(varstring); end + if ~isempty(varstring), level = str2num(varstring); end d = abs(level - levels); % crude distance - ind = find(min(d) == d); % multiple minima possible + ind = find(min(d) == d); % multiple minima possible lvlind = ind(1); % use the first one level = levels(lvlind); @@ -332,14 +332,14 @@ if ~isempty(varstring) nums = str2num(varstring); - if (length(nums) ~= 2) + if (length(nums) ~= 2) error('Did not get two indices for the lat lon pair.') end lat = nums(1); lon = nums(2); end -% For simplicity I will pick the grid cell whose center is closest +% For simplicity I will pick the grid cell whose center is closest % to the point of interest. This is not a perfect solution, should really % check the neighboring cells to see if it is INSIDE the cell, % but if you are interested in that level of accuracy, you're on your own. Modified: DART/branches/development/matlab/GetPe2lyrInfo.m =================================================================== --- DART/branches/development/matlab/GetPe2lyrInfo.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/GetPe2lyrInfo.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -201,7 +201,7 @@ fprintf('If not, please enter one of: %s\n',str) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), pgvar = deblank(varstring); end +if ~isempty(varstring), pgvar = deblank(varstring); end function [time, timeind] = GetTime(times, deftime) @@ -213,10 +213,10 @@ min(times),max(times)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), time = str2num(varstring); end +if ~isempty(varstring), time = str2num(varstring); end d = abs(time - times); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible timeind = ind(1); % use the first one time = times(timeind); @@ -232,10 +232,10 @@ min(levels),max(levels)) varstring = input('we''ll use the closest (no syntax required)\n','s'); -if ~isempty(varstring), level = str2num(varstring); end +if ~isempty(varstring), level = str2num(varstring); end d = abs(level - levels); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible lvlind = ind(1); % use the first one level = levels(lvlind); @@ -244,15 +244,15 @@ %---------------------------------------------------------------------- if (nargin == 2), lon = deflon; else lon = 255.0; end -fprintf('Default longitude is %f, if this is OK, ;\n',lon) +fprintf('Default longitude is %f, if this is OK, ;\n',lon) fprintf('If not, enter a longitude between %.2f and %.2f, we use the closest.\n', ... min(lons),max(lons)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), lon = str2num(varstring); end +if ~isempty(varstring), lon = str2num(varstring); end d = abs(lon - lons); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible lonind = ind(1); % use the first one lon = lons(lonind); @@ -266,10 +266,10 @@ min(lats),max(lats)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), lat = str2num(varstring); end +if ~isempty(varstring), lat = str2num(varstring); end d = abs(lat - lats); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible latind = ind(1); % use the first one lat = lats(latind); Modified: DART/branches/development/matlab/GetTIEGCMInfo.m =================================================================== --- DART/branches/development/matlab/GetTIEGCMInfo.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/GetTIEGCMInfo.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -74,7 +74,7 @@ comp_var = GetVar(prognostic_vars, base_var); [comp_lvl, comp_lvlind] = GetLevel( comp_var,levels, base_lvlind); - pinfo.model = model; + pinfo.model = model; pinfo.base_var = base_var; pinfo.comp_var = comp_var; pinfo.base_time = base_time; @@ -148,8 +148,8 @@ if ( exist(pstruct.truth_file,'file') ) pinfo.truth_file = pstruct.truth_file; end - + case 'plotphasespace' disp('Getting information for the ''X'' variable.') @@ -216,11 +216,11 @@ for i = 2:length(prognostic_vars), str = sprintf(' %s %s ',str,prognostic_vars{i}); end -fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) +fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) fprintf('If not, please enter one of: %s\n',str) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), pgvar = strtrim(varstring); end +if ~isempty(varstring), pgvar = strtrim(varstring); end inds = strfind(pgvar,','); pgvar(inds) = ''; @@ -254,7 +254,7 @@ timeinds = 1:ntimes; d = abs(tindex - timeinds); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible timeind = ind(1); % use the first one time = times(timeind); @@ -271,7 +271,7 @@ 1,length(levels)) varstring = input('we''ll use the closest (no syntax required)\n','s'); -if ~isempty(varstring), lvlind = str2num(varstring); end +if ~isempty(varstring), lvlind = str2num(varstring); end level = levels(lvlind); @@ -281,15 +281,15 @@ %---------------------------------------------------------------------- if (nargin == 3), lon = deflon; else lon = 255.0-360.0; end -fprintf('Default longitude is %f, if this is OK, ;\n',lon) +fprintf('Default longitude is %f, if this is OK, ;\n',lon) fprintf('If not, enter a longitude between %.2f and %.2f, we use the closest.\n', ... min(lons),max(lons)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), lon = str2num(varstring); end +if ~isempty(varstring), lon = str2num(varstring); end d = abs(lon - lons); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible lonind = ind(1); % use the first one lon = lons(lonind); @@ -304,10 +304,10 @@ min(lats),max(lats)) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), lat = str2num(varstring); end +if ~isempty(varstring), lat = str2num(varstring); end d = abs(lat - lats); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible latind = ind(1); % use the first one lat = lats(latind); Modified: DART/branches/development/matlab/GetWRFInfo.m =================================================================== --- DART/branches/development/matlab/GetWRFInfo.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/GetWRFInfo.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -48,14 +48,14 @@ polar = varget(fname, 'POLAR'); %% Get the global metadata from a WRF DART diagnostic netCDF file. -% If there is only one domain, we know what to do. +% If there is only one domain, we know what to do. % otherwise, ask which domain is of interest. dinfo = nc_getdiminfo(fname,'domain'); % no graceful error num_domains = dinfo.Length; dID = 1; -if (num_domains > 1) +if (num_domains > 1) dID = GetDomain(num_domains); end @@ -175,7 +175,7 @@ % So now I have to figure out if the posterior and prior copy metadata match. for i = 1:copy, - copyi = get_copy_index(pinfo_in.posterior_file,copymetadata{i}); + copyi = get_copy_index(pinfo_in.posterior_file,copymetadata{i}); pstruct.postcopyindices = copyi; end @@ -245,13 +245,13 @@ function domainid = GetDomainID(ndomains) %---------------------------------------------------------------------- -fprintf('There are %d domains. Default is to use domain %d.\n.',ndomains,ndomains) +fprintf('There are %d domains. Default is to use domain %d.\n.',ndomains,ndomains) fprintf('If this is OK, ; If not, enter domain of interest:\n') domainid = input('(no syntax required)\n'); -if ~isempty(domainid), domainid = ndomains; end +if ~isempty(domainid), domainid = ndomains; end -if ( (domainid > 0) && (domainid <= ndomains)) +if ( (domainid > 0) && (domainid <= ndomains)) error('domain must be between 1 and %d, you entered %d',ndomains,domainid) end @@ -265,11 +265,11 @@ for i = 2:length(prognostic_vars), str = sprintf(' %s %s ',str,prognostic_vars{i}); end -fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) +fprintf('Default variable is ''%s'', if this is OK, ;\n',pgvar) fprintf('If not, please enter one of: %s\n',str) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), pgvar = deblank(varstring); end +if ~isempty(varstring), pgvar = deblank(varstring); end @@ -284,7 +284,7 @@ time = deftime; tindex = find(times == deftime); else - if (ntimes < 2) + if (ntimes < 2) tindex = round(ntimes/2); else tindex = 1; @@ -297,11 +297,11 @@ fprintf('Pertaining to %s and %s \n',datestr(times(1)),datestr(times(ntimes))) varstring = input('(no syntax required)\n','s'); -if ~isempty(varstring), tindex = str2num(varstring); end +if ~isempty(varstring), tindex = str2num(varstring); end timeinds = 1:ntimes; d = abs(tindex - timeinds); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible timeind = ind(1); % use the first one time = times(timeind); @@ -324,7 +324,7 @@ else levelvar = varinfo.Dimension{leveldim}; - dinfo = nc_getdiminfo(fname,levelvar); + dinfo = nc_getdiminfo(fname,levelvar); levels = 1:dinfo.Length; if (isempty(level)), level = levels(1); end @@ -334,10 +334,10 @@ min(levels),max(levels)) varstring = input('we''ll use the closest (no syntax required)\n','s'); - if ~isempty(varstring), level = str2num(varstring); end + if ~isempty(varstring), level = str2num(varstring); end d = abs(level - levels); % crude distance - ind = find(min(d) == d); % multiple minima possible + ind = find(min(d) == d); % multiple minima possible lvlind = ind(1); % use the first one level = levels(lvlind); @@ -409,7 +409,7 @@ if ~isempty(varstring) nums = str2num(varstring); - if (length(nums) ~= 2) + if (length(nums) ~= 2) error('Did not get two indices for the lat lon pair.') end latind = nums(1); @@ -431,11 +431,11 @@ loninds = 1:nlon; d = abs(latind - latinds); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible latind = ind(1); % use the first one d = abs(lonind - loninds); % crude distance -ind = find(min(d) == d); % multiple minima possible +ind = find(min(d) == d); % multiple minima possible lonind = ind(1); % use the first one lat = latmat(latind,lonind); @@ -448,10 +448,10 @@ % % function dist = arcdist(lat,lon,latvec,lonvec) % -% lat,lon MUST be scalars +% lat,lon MUST be scalars % lat1,lon1 lat1,lon1 can be any shape (but must match each other) % -% enter: +% enter: % lat1,lon1 = lat, lon (in degrees) % lat2,lon2 = lat, lon (for loc 2) % returns: @@ -459,7 +459,7 @@ % % Assumes a spherical earth and fractional lat/lon coords % -% Example (1 degree at the equator): +% Example (1 degree at the equator): % dist = arcdist(0.0,0.0,0.0,1.0) % 1 degree longitude % dist = arcdist(0.0,0.0,1.0,0.0) % 1 degree latitude % dist = arcdist(60.0,0.0,60.0,1.0) % 1 degree longitude at a high latitude @@ -480,7 +480,7 @@ ang1 = cos(colat2).*cos(colat1); ang2 = sin(colat2).*sin(colat1).*cos(alpha); -if ( prod(Dlat1) == 1 ) +if ( prod(Dlat1) == 1 ) dist = acos(ang1 + ang2)*r; else dist = reshape(acos(ang1 + ang2)*r,Dlat2); @@ -509,7 +509,7 @@ function x = varget(filename,varname) -%% get a varible from the netcdf file, if it does not exist, +%% get a varible from the netcdf file, if it does not exist, % do not die such a theatrical death ... return an empty. if ( nc_isvar(filename,varname) ) Modified: DART/branches/development/matlab/ParseAlphaNumerics.m =================================================================== --- DART/branches/development/matlab/ParseAlphaNumerics.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/ParseAlphaNumerics.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -1,5 +1,5 @@ function [vrbl, vrbl_inds] = ParseAlphaNumerics(IDstring) -%% ParseAlphaNumerics - extricates a variable name from subsequent IDs +%% ParseAlphaNumerics - extricates a variable name from subsequent IDs % str1 = ' X 1 3 4 89' % [alpha, numerics] = ParseAlphaNumerics(str1) % alpha = 'X' Modified: DART/branches/development/matlab/PlotBins.m =================================================================== --- DART/branches/development/matlab/PlotBins.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/PlotBins.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -116,7 +116,7 @@ clf; iplot = 0; for ivar = pinfo.var_inds, iplot = iplot + 1; - + truth = get_hyperslab('fname',pinfo.truth_file, 'varname',pinfo.var, ... 'copyindex',truth_index, 'stateindex',ivar, ... 'tindex1',pinfo.truth_time(1), 'tcount',pinfo.truth_time(2)); Modified: DART/branches/development/matlab/PlotCEnsErrSpread.m =================================================================== --- DART/branches/development/matlab/PlotCEnsErrSpread.m 2012-05-09 22:05:37 UTC (rev 5733) +++ DART/branches/development/matlab/PlotCEnsErrSpread.m 2012-05-09 22:06:41 UTC (rev 5734) @@ -14,7 +14,7 @@ % this sets start/stop time indices for both truth and diagn file now pinfo = CheckModelCompatibility(pinfo.truth_file, pinfo.diagn_file) -model = nc_attget(pinfo.truth_file, nc_global, 'model'); +model = nc_attget(pinfo.truth_file, nc_global, 'model'); timeunits = nc_attget(pinfo.truth_file,'time','units'); nvars = 4; @@ -28,9 +28,9 @@ rms = zeros(num_times, nvars, num_levels); sd_final = zeros(num_times, nvars, num_levels); -% Get the indices for the true state, ensemble mean and spread -% The metadata is queried to determine which "copy" is appropriate. -truth_index = get_copy_index(pinfo.truth_file, 'true state' ); +% Get the indices for the true state, ensemble mean and spread +% The metadata is queried to determine which "copy" is appropriate. +truth_index = get_copy_index(pinfo.truth_file, 'true state' ); ens_mean_index = get_copy_index(pinfo.diagn_file, 'ensemble mean'); ens_spread_index = get_copy_index(pinfo.diagn_file, 'ensemble spread'); @@ -89,7 +89,7 @@ rms(:, ivar, ilevel) = mean(abs(ens_err),2); sd_final(:, ivar, ilevel) = mean(sd,2); - + @@ Diff output truncated at 40000 characters. @@ From nancy at ucar.edu Wed May 9 16:12:06 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 16:12:06 -0600 Subject: [Dart-dev] [5735] DART/branches/development/models/clm/work: removed random_nr_mod Message-ID: Revision: 5735 Author: thoar Date: 2012-05-09 16:12:06 -0600 (Wed, 09 May 2012) Log Message: ----------- removed random_nr_mod Modified Paths: -------------- DART/branches/development/models/clm/work/path_names_clm_to_dart DART/branches/development/models/clm/work/path_names_create_fixed_network_seq DART/branches/development/models/clm/work/path_names_create_obs_sequence DART/branches/development/models/clm/work/path_names_dart_to_clm DART/branches/development/models/clm/work/path_names_filter DART/branches/development/models/clm/work/path_names_model_mod_check DART/branches/development/models/clm/work/path_names_obs_diag DART/branches/development/models/clm/work/path_names_obs_seq_to_netcdf DART/branches/development/models/clm/work/path_names_obs_sequence_tool DART/branches/development/models/clm/work/path_names_perfect_model_obs DART/branches/development/models/clm/work/path_names_restart_file_tool -------------- next part -------------- Modified: DART/branches/development/models/clm/work/path_names_clm_to_dart =================================================================== --- DART/branches/development/models/clm/work/path_names_clm_to_dart 2012-05-09 22:06:41 UTC (rev 5734) +++ DART/branches/development/models/clm/work/path_names_clm_to_dart 2012-05-09 22:12:06 UTC (rev 5735) @@ -5,7 +5,6 @@ models/clm/model_mod.f90 mpi_utilities/null_mpi_utilities_mod.f90 obs_kind/obs_kind_mod.f90 -random_nr/random_nr_mod.f90 random_seq/random_seq_mod.f90 time_manager/time_manager_mod.f90 utilities/utilities_mod.f90 Modified: DART/branches/development/models/clm/work/path_names_create_fixed_network_seq =================================================================== --- DART/branches/development/models/clm/work/path_names_create_fixed_network_seq 2012-05-09 22:06:41 UTC (rev 5734) +++ DART/branches/development/models/clm/work/path_names_create_fixed_network_seq 2012-05-09 22:12:06 UTC (rev 5735) @@ -7,7 +7,6 @@ obs_kind/obs_kind_mod.f90 obs_sequence/create_fixed_network_seq.f90 obs_sequence/obs_sequence_mod.f90 -random_nr/random_nr_mod.f90 random_seq/random_seq_mod.f90 time_manager/time_manager_mod.f90 utilities/utilities_mod.f90 Modified: DART/branches/development/models/clm/work/path_names_create_obs_sequence =================================================================== --- DART/branches/development/models/clm/work/path_names_create_obs_sequence 2012-05-09 22:06:41 UTC (rev 5734) +++ DART/branches/development/models/clm/work/path_names_create_obs_sequence 2012-05-09 22:12:06 UTC (rev 5735) @@ -9,7 +9,6 @@ obs_model/obs_model_mod.f90 obs_sequence/create_obs_sequence.f90 obs_sequence/obs_sequence_mod.f90 -random_nr/random_nr_mod.f90 random_seq/random_seq_mod.f90 time_manager/time_manager_mod.f90 utilities/utilities_mod.f90 Modified: DART/branches/development/models/clm/work/path_names_dart_to_clm =================================================================== --- DART/branches/development/models/clm/work/path_names_dart_to_clm 2012-05-09 22:06:41 UTC (rev 5734) +++ DART/branches/development/models/clm/work/path_names_dart_to_clm 2012-05-09 22:12:06 UTC (rev 5735) @@ -5,7 +5,6 @@ models/clm/model_mod.f90 mpi_utilities/null_mpi_utilities_mod.f90 obs_kind/obs_kind_mod.f90 -random_nr/random_nr_mod.f90 random_seq/random_seq_mod.f90 time_manager/time_manager_mod.f90 utilities/utilities_mod.f90 Modified: DART/branches/development/models/clm/work/path_names_filter =================================================================== --- DART/branches/development/models/clm/work/path_names_filter 2012-05-09 22:06:41 UTC (rev 5734) +++ DART/branches/development/models/clm/work/path_names_filter 2012-05-09 22:12:06 UTC (rev 5735) @@ -12,7 +12,6 @@ obs_kind/obs_kind_mod.f90 obs_model/obs_model_mod.f90 obs_sequence/obs_sequence_mod.f90 -random_nr/random_nr_mod.f90 random_seq/random_seq_mod.f90 reg_factor/reg_factor_mod.f90 smoother/smoother_mod.f90 Modified: DART/branches/development/models/clm/work/path_names_model_mod_check =================================================================== --- DART/branches/development/models/clm/work/path_names_model_mod_check 2012-05-09 22:06:41 UTC (rev 5734) +++ DART/branches/development/models/clm/work/path_names_model_mod_check 2012-05-09 22:12:06 UTC (rev 5735) @@ -6,7 +6,6 @@ mpi_utilities/null_mpi_utilities_mod.f90 obs_def/obs_def_mod.f90 obs_kind/obs_kind_mod.f90 -random_nr/random_nr_mod.f90 random_seq/random_seq_mod.f90 time_manager/time_manager_mod.f90 utilities/utilities_mod.f90 Modified: DART/branches/development/models/clm/work/path_names_obs_diag =================================================================== --- DART/branches/development/models/clm/work/path_names_obs_diag 2012-05-09 22:06:41 UTC (rev 5734) +++ DART/branches/development/models/clm/work/path_names_obs_diag 2012-05-09 22:12:06 UTC (rev 5735) @@ -7,7 +7,6 @@ obs_def/obs_def_mod.f90 obs_kind/obs_kind_mod.f90 obs_sequence/obs_sequence_mod.f90 -random_nr/random_nr_mod.f90 random_seq/random_seq_mod.f90 sort/sort_mod.f90 time_manager/time_manager_mod.f90 Modified: DART/branches/development/models/clm/work/path_names_obs_seq_to_netcdf =================================================================== --- DART/branches/development/models/clm/work/path_names_obs_seq_to_netcdf 2012-05-09 22:06:41 UTC (rev 5734) +++ DART/branches/development/models/clm/work/path_names_obs_seq_to_netcdf 2012-05-09 22:12:06 UTC (rev 5735) @@ -7,7 +7,6 @@ obs_kind/obs_kind_mod.f90 obs_sequence/obs_seq_to_netcdf.f90 obs_sequence/obs_sequence_mod.f90 -random_nr/random_nr_mod.f90 random_seq/random_seq_mod.f90 time_manager/schedule_mod.f90 time_manager/time_manager_mod.f90 Modified: DART/branches/development/models/clm/work/path_names_obs_sequence_tool =================================================================== --- DART/branches/development/models/clm/work/path_names_obs_sequence_tool 2012-05-09 22:06:41 UTC (rev 5734) +++ DART/branches/development/models/clm/work/path_names_obs_sequence_tool 2012-05-09 22:12:06 UTC (rev 5735) @@ -8,7 +8,6 @@ obs_kind/obs_kind_mod.f90 obs_sequence/obs_sequence_mod.f90 obs_sequence/obs_sequence_tool.f90 -random_nr/random_nr_mod.f90 random_seq/random_seq_mod.f90 time_manager/time_manager_mod.f90 utilities/utilities_mod.f90 Modified: DART/branches/development/models/clm/work/path_names_perfect_model_obs =================================================================== --- DART/branches/development/models/clm/work/path_names_perfect_model_obs 2012-05-09 22:06:41 UTC (rev 5734) +++ DART/branches/development/models/clm/work/path_names_perfect_model_obs 2012-05-09 22:12:06 UTC (rev 5735) @@ -12,7 +12,6 @@ obs_model/obs_model_mod.f90 obs_sequence/obs_sequence_mod.f90 perfect_model_obs/perfect_model_obs.f90 -random_nr/random_nr_mod.f90 random_seq/random_seq_mod.f90 reg_factor/reg_factor_mod.f90 sort/sort_mod.f90 Modified: DART/branches/development/models/clm/work/path_names_restart_file_tool =================================================================== --- DART/branches/development/models/clm/work/path_names_restart_file_tool 2012-05-09 22:06:41 UTC (rev 5734) +++ DART/branches/development/models/clm/work/path_names_restart_file_tool 2012-05-09 22:12:06 UTC (rev 5735) @@ -10,7 +10,6 @@ obs_def/obs_def_mod.f90 obs_kind/obs_kind_mod.f90 obs_sequence/obs_sequence_mod.f90 -random_nr/random_nr_mod.f90 random_seq/random_seq_mod.f90 reg_factor/reg_factor_mod.f90 sort/sort_mod.f90 From nancy at ucar.edu Wed May 9 16:13:59 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 16:13:59 -0600 Subject: [Dart-dev] [5736] DART/branches/development/models/clm: Removed reference to random_nr_mod. Message-ID: Revision: 5736 Author: thoar Date: 2012-05-09 16:13:59 -0600 (Wed, 09 May 2012) Log Message: ----------- Removed reference to random_nr_mod. Modified Paths: -------------- DART/branches/development/models/clm/clm_to_dart.html DART/branches/development/models/clm/dart_to_clm.html -------------- next part -------------- Modified: DART/branches/development/models/clm/clm_to_dart.html =================================================================== --- DART/branches/development/models/clm/clm_to_dart.html 2012-05-09 22:12:06 UTC (rev 5735) +++ DART/branches/development/models/clm/clm_to_dart.html 2012-05-09 22:13:59 UTC (rev 5736) @@ -151,7 +151,6 @@ model_mod null_mpi_utilities_mod obs_kind_mod -random_nr_mod random_seq_mod time_manager_mod types_mod Modified: DART/branches/development/models/clm/dart_to_clm.html =================================================================== --- DART/branches/development/models/clm/dart_to_clm.html 2012-05-09 22:12:06 UTC (rev 5735) +++ DART/branches/development/models/clm/dart_to_clm.html 2012-05-09 22:13:59 UTC (rev 5736) @@ -185,7 +185,6 @@ model_mod null_mpi_utilities_mod obs_kind_mod -random_nr_mod random_seq_mod time_manager_mod types_mod From nancy at ucar.edu Wed May 9 16:15:51 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 16:15:51 -0600 Subject: [Dart-dev] [5737] DART/branches/development/models/clm/model_mod.f90: Removed unused types_mod:NAN Message-ID: Revision: 5737 Author: thoar Date: 2012-05-09 16:15:51 -0600 (Wed, 09 May 2012) Log Message: ----------- Removed unused types_mod:NAN The implementation of NaN was not portable (as Jeff predicted ...) and so was not terribly useful. I did not even port it to the development branch. Modified Paths: -------------- DART/branches/development/models/clm/model_mod.f90 -------------- next part -------------- Modified: DART/branches/development/models/clm/model_mod.f90 =================================================================== --- DART/branches/development/models/clm/model_mod.f90 2012-05-09 22:13:59 UTC (rev 5736) +++ DART/branches/development/models/clm/model_mod.f90 2012-05-09 22:15:51 UTC (rev 5737) @@ -20,7 +20,7 @@ ! Modules that are absolutely required for use are listed -use types_mod, only : r4, r8, SECPERDAY, MISSING_R8, NAN, & +use types_mod, only : r4, r8, SECPERDAY, MISSING_R8, & MISSING_I, MISSING_R4, rad2deg, deg2rad, PI, & obstypelength use time_manager_mod, only : time_type, set_time, set_date, get_date, get_time,& From nancy at ucar.edu Wed May 9 16:42:30 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 16:42:30 -0600 Subject: [Dart-dev] [5738] DART/branches/development/random_nr/test_reseed.f90: trying to resolve a svn problem. Message-ID: Revision: 5738 Author: thoar Date: 2012-05-09 16:42:30 -0600 (Wed, 09 May 2012) Log Message: ----------- trying to resolve a svn problem. file is supposed to be empty and removed. Added Paths: ----------- DART/branches/development/random_nr/test_reseed.f90 -------------- next part -------------- Copied: DART/branches/development/random_nr/test_reseed.f90 (from rev 5611, DART/branches/development/random_nr/test_reseed.f90) =================================================================== From nancy at ucar.edu Wed May 9 16:43:11 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 16:43:11 -0600 Subject: [Dart-dev] [5739] DART/branches/development/random_nr/test_reseed.f90: Really removing the stupid thing. Message-ID: Revision: 5739 Author: thoar Date: 2012-05-09 16:43:11 -0600 (Wed, 09 May 2012) Log Message: ----------- Really removing the stupid thing. Removed Paths: ------------- DART/branches/development/random_nr/test_reseed.f90 -------------- next part -------------- Deleted: DART/branches/development/random_nr/test_reseed.f90 =================================================================== From nancy at ucar.edu Wed May 9 16:56:37 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Wed, 09 May 2012 16:56:37 -0600 Subject: [Dart-dev] [5740] DART/branches/development: Adding the support for the flux tower observations and incorporating what used to be in the obs_def_land_mod .f90 Message-ID: Revision: 5740 Author: thoar Date: 2012-05-09 16:56:36 -0600 (Wed, 09 May 2012) Log Message: ----------- Adding the support for the flux tower observations and incorporating what used to be in the obs_def_land_mod.f90 The DEFAULT_obs_kind_mod.f90 also had a lot of hanging whitespace that I removed. Modified Paths: -------------- DART/branches/development/obs_def/obs_def_tower_mod.f90 DART/branches/development/obs_kind/DEFAULT_obs_kind_mod.F90 -------------- next part -------------- Modified: DART/branches/development/obs_def/obs_def_tower_mod.f90 =================================================================== --- DART/branches/development/obs_def/obs_def_tower_mod.f90 2012-05-09 22:43:11 UTC (rev 5739) +++ DART/branches/development/obs_def/obs_def_tower_mod.f90 2012-05-09 22:56:36 UTC (rev 5740) @@ -3,9 +3,23 @@ ! http://www.image.ucar.edu/DAReS/DART/DART_download ! BEGIN DART PREPROCESS KIND LIST -!TOWER_TEMPERATURE, KIND_TEMPERATURE, COMMON_CODE -!TOWER_U_WIND_COMPONENT, KIND_U_WIND_COMPONENT, COMMON_CODE -!TOWER_V_WIND_COMPONENT, KIND_V_WIND_COMPONENT, COMMON_CODE +!SOIL_TEMPERATURE, KIND_SOIL_TEMPERATURE, COMMON_CODE +!LAYER_LIQUID_WATER, KIND_LIQUID_WATER, COMMON_CODE +!LAYER_ICE, KIND_ICE, COMMON_CODE +!SNOW_THICKNESS, KIND_SNOW_THICKNESS, COMMON_CODE +!SNOW_WATER, KIND_SNOW_WATER, COMMON_CODE +!MODIS_SNOWCOVER_FRAC, KIND_SNOWCOVER_FRAC, COMMON_CODE +!LEAF_CARBON, KIND_LEAF_CARBON, COMMON_CODE +!LEAF_AREA_INDEX, KIND_LEAF_AREA_INDEX, COMMON_CODE +!TOWER_AIR_TEMPERATURE, KIND_TEMPERATURE, COMMON_CODE +!TOWER_SOIL_TEMPERATURE, KIND_TEMPERATURE, COMMON_CODE +!TOWER_U_WIND_COMPONENT, KIND_U_WIND_COMPONENT, COMMON_CODE +!TOWER_V_WIND_COMPONENT, KIND_V_WIND_COMPONENT, COMMON_CODE +!TOWER_LATENT_HEAT_FLUX, KIND_LATENT_HEAT_FLUX, COMMON_CODE +!TOWER_SENSIBLE_HEAT_FLUX, KIND_SENSIBLE_HEAT_FLUX, COMMON_CODE +!TOWER_GLOBAL_RADIATION, KIND_RADIATION, COMMON_CODE +!TOWER_NETC_ECO_EXCHANGE, KIND_NET_CARBON_PRODUCTION, COMMON_CODE +!TOWER_NET_CARBON_FLUX, KIND_NET_CARBON_FLUX, COMMON_CODE ! END DART PREPROCESS KIND LIST ! Modified: DART/branches/development/obs_kind/DEFAULT_obs_kind_mod.F90 =================================================================== --- DART/branches/development/obs_kind/DEFAULT_obs_kind_mod.F90 2012-05-09 22:43:11 UTC (rev 5739) +++ DART/branches/development/obs_kind/DEFAULT_obs_kind_mod.F90 2012-05-09 22:56:36 UTC (rev 5740) @@ -50,13 +50,13 @@ ! generate this table automatically. ! F90 currently has a maximum length of 32 characters for the NAME of -! any Fortran PARAMETER. +! any Fortran PARAMETER. integer, parameter, public :: paramname_length = 32 ! Definition and public access to the observation types/kinds -! Unique index values associated with each observation type and -! kind strings are defined here. +! Unique index values associated with each observation type and +! kind strings are defined here. integer, parameter, public :: & KIND_RAW_STATE_VARIABLE = 0, & @@ -85,26 +85,26 @@ KIND_POTENTIAL_TEMPERATURE = 23, & KIND_SOIL_MOISTURE = 24, & KIND_SURFACE_ELEVATION = 25 - + ! kinds for Gravity Wave Drag (CAM - kevin) integer, parameter, public :: & KIND_GRAV_WAVE_DRAG_EFFIC = 26, & KIND_GRAV_WAVE_STRESS_FRACTION = 27 - + ! kinds for simple advection model integer, parameter, public :: & KIND_TRACER_SOURCE = 28, & KIND_TRACER_CONCENTRATION = 29, & KIND_MEAN_SOURCE = 30, & KIND_SOURCE_PHASE = 31 - + ! kind for power-weighted precipitation fall speed ! and a few other kinds that were missing from the ! collection of fractions and mixing ratio definitions. ! (CONCENTRATION -> CONCENTR because the max len of ! these strings is still 32 chars.) -! WARNING: the current models use +! WARNING: the current models use ! KIND_CLOUD_LIQUID_WATER and KIND_CLOUD_ICE ! for mixing ratios. because current models are ! using them, we can't make them consistent with @@ -115,7 +115,7 @@ KIND_POWER_WEIGHTED_FALL_SPEED = 32, & KIND_CLOUDWATER_MIXING_RATIO = 33, & KIND_ICE_MIXING_RATIO = 34, & - KIND_DROPLET_NUMBER_CONCENTR = 35, & + KIND_DROPLET_NUMBER_CONCENTR = 35, & KIND_SNOW_NUMBER_CONCENTR = 36, & KIND_RAIN_NUMBER_CONCENTR = 37, & KIND_GRAUPEL_NUMBER_CONCENTR = 38, & @@ -123,10 +123,10 @@ KIND_ICE_FRACTION = 40, & KIND_RELATIVE_HUMIDITY = 41 -! kinds for TIEgcm +! kinds for TIEgcm integer, parameter, public :: & KIND_ELECTRON_DENSITY = 42 - + ! kinds for generic parameters that aren't going to be ! directly observed but are going to be adjusted by the ! assimilation. @@ -153,7 +153,7 @@ KIND_DRY_LAND = 54, & KIND_SEA_SURFACE_PRESSURE = 55, & KIND_W_CURRENT_COMPONENT = 56 - + ! proposed new kinds for COSMIC GPS/RO obs ! (currently unused) integer, parameter, public :: & @@ -165,11 +165,11 @@ KIND_INFRARED_RADIANCE = 60, & KIND_INFRARED_BRIGHT_TEMP = 61, & KIND_LANDMASK = 62 - -! kind for unstructured grids + +! kind for unstructured grids integer, parameter, public :: & KIND_EDGE_NORMAL_SPEED = 63 - + ! kinds for planetary remote sensing (wglawson, c.lee) integer, parameter, public :: & KIND_SKIN_TEMPERATURE = 70, & @@ -198,7 +198,7 @@ KIND_VORTEX_LAT = 82, & KIND_VORTEX_PMIN = 83, & KIND_VORTEX_WMAX = 84 - + ! kinds for COAMPS (Tim Whitcomb) integer, parameter, public :: & KIND_EXNER_FUNCTION = 85, & @@ -207,15 +207,15 @@ KIND_VERTLEVEL = 88, & KIND_MICROWAVE_BRIGHT_TEMP = 89 -! kinds for NAAPS (Walter R. Sessions) +! kinds for NAAPS (Walter R. Sessions) integer, parameter, public :: & - KIND_INTEGRATED_SULFATE = 90, & + KIND_INTEGRATED_SULFATE = 90, & KIND_INTEGRATED_DUST = 91, & KIND_INTEGRATED_SMOKE = 92, & KIND_INTEGRATED_SEASALT = 93, & KIND_INTEGRATED_AOD = 94, & - KIND_SO2 = 95, & - KIND_SULFATE = 96, & + KIND_SO2 = 95, & + KIND_SULFATE = 96, & KIND_DUST = 97, & KIND_SMOKE = 98, & KIND_SEASALT = 99 @@ -228,16 +228,31 @@ KIND_HAIL_VOLUME = 103, & KIND_DIFFERENTIAL_REFLECTIVITY = 104, & KIND_SPECIFIC_DIFFERENTIAL_PHASE = 105, & - KIND_FLASH_RATE_2D = 106 + KIND_FLASH_RATE_2D = 106 +! kinds for CLM - Community Land Model (Tim Hoar) +integer, parameter, public :: & + KIND_SNOW_THICKNESS = 107, & + KIND_SNOW_WATER = 108, & + KIND_SNOWCOVER_FRAC = 109, & + KIND_LIQUID_WATER = 110, & + KIND_ICE = 111, & + KIND_LEAF_CARBON = 112, & + KIND_LEAF_AREA_INDEX = 113, & + KIND_NET_CARBON_FLUX = 114, & + KIND_LATENT_HEAT_FLUX = 115, & + KIND_SENSIBLE_HEAT_FLUX = 116, & + KIND_RADIATION = 117, & + KIND_NET_CARBON_PRODUCTION = 118 + !! PRIVATE ONLY TO THIS MODULE. see comment below near the max_obs_specific !! declaration. -integer, parameter :: max_obs_generic = 106 +integer, parameter :: max_obs_generic = 118 !---------------------------------------------------------------------------- -! This list is autogenerated by the 'preprocess' program. To add new +! This list is autogenerated by the 'preprocess' program. To add new ! observation types (e.g. AIRS_U_WIND_COMPONENT), edit the obs_def_x_mod.f90 -! files and also add (or remove) them from the 'input_files' variable of +! files and also add (or remove) them from the 'input_files' variable of ! the &preprocess_nml namelist in the model-specific work/input.nml file. ! Unique index values associated with each observation type string are @@ -264,7 +279,7 @@ !! being non-backwards compatible. for now, punt on both type and kind !! and start trying to use specific and generic (ok, which do map to type !! and kind, respectively). using intermediate names might make the transition -!! less painful. right now, many(most) of the subroutine names or args +!! less painful. right now, many(most) of the subroutine names or args !! which are public are using 'kind' where it needs to be 'type'. integer, parameter :: max_obs_specific = max_obs_kinds @@ -305,7 +320,7 @@ character(len = paramname_length) :: name end type obs_kind_type -! An obs_kind_name_type is defined by the preprocess program to store +! An obs_kind_name_type is defined by the preprocess program to store ! the association between obs_kind index numbers and string names. ! raw is index 0, so this needs to match. revisit the direct indexing ! since we have an index in the table -- redundant info? @@ -458,8 +473,20 @@ obs_kind_names(105) = obs_kind_type(KIND_SPECIFIC_DIFFERENTIAL_PHASE, 'KIND_SPECIFIC_DIFFERENTIAL_PHASE') obs_kind_names(106) = obs_kind_type(KIND_FLASH_RATE_2D, 'KIND_FLASH_RATE_2D') +obs_kind_names(107) = obs_kind_type(KIND_SNOW_THICKNESS ,'KIND_SNOW_THICKNESS') +obs_kind_names(108) = obs_kind_type(KIND_SNOW_WATER ,'KIND_SNOW_WATER') +obs_kind_names(109) = obs_kind_type(KIND_SNOWCOVER_FRAC ,'KIND_SNOWCOVER_FRAC') +obs_kind_names(110) = obs_kind_type(KIND_LIQUID_WATER ,'KIND_LIQUID_WATER') +obs_kind_names(111) = obs_kind_type(KIND_ICE ,'KIND_ICE') +obs_kind_names(112) = obs_kind_type(KIND_LEAF_CARBON ,'KIND_LEAF_CARBON') +obs_kind_names(113) = obs_kind_type(KIND_LEAF_AREA_INDEX ,'KIND_LEAF_AREA_INDEX') +obs_kind_names(114) = obs_kind_type(KIND_NET_CARBON_FLUX ,'KIND_NET_CARBON_FLUX') +obs_kind_names(115) = obs_kind_type(KIND_LATENT_HEAT_FLUX ,'KIND_LATENT_HEAT_FLUX') +obs_kind_names(116) = obs_kind_type(KIND_SENSIBLE_HEAT_FLUX ,'KIND_SENSIBLE_HEAT_FLUX') +obs_kind_names(117) = obs_kind_type(KIND_RADIATION ,'KIND_RADIATION') +obs_kind_names(118) = obs_kind_type(KIND_NET_CARBON_PRODUCTION ,'KIND_NET_CARBON_PRODUCTION') -! count here, then output below +! count here, then output below num_kind_assimilate = 0 do i = 1, max_obs_specific @@ -561,7 +588,7 @@ if ( .not. module_initialized ) call initialize_module ! Need to search through the first map column to find this obs_def_index value -! Then return the index into table in this module from corresponding row in +! Then return the index into table in this module from corresponding row in ! second column. do i = 1, max_obs_specific if(map(1, i) == obs_def_index) then @@ -606,7 +633,7 @@ ! handling more readable. function get_raw_obs_kind_name(obs_kind_ind) - + ! Returns observation kind name integer, intent(in) :: obs_kind_ind @@ -666,7 +693,7 @@ integer :: i character(len=len(obs_kind_name)) :: string1 - + if (.not. module_initialized) call initialize_module string1 = adjustl(obs_kind_name) @@ -699,7 +726,7 @@ !---------------------------------------------------------------------------- function get_num_raw_obs_kinds() - + ! Accessor function to return observation *kind* count integer :: get_num_raw_obs_kinds @@ -774,8 +801,8 @@ is_ascii = ascii_file_format(fform) ! Write the 20 character identifier to indicate the start of a kind table. -! To maintain complete backwards compatibility with the original read -! code this string must start in column 1. +! To maintain complete backwards compatibility with the original read +! code this string must start in column 1. ! you cannot use: write(ifile, *) 'string' because the output string ! will start in col 2. the string either has to be part of the format ! argument to write(), or you have to use a separate format statement. @@ -858,7 +885,7 @@ is_ascii = ascii_file_format(fform) -! Read the 20 character identifier which identifies the start +! Read the 20 character identifier which identifies the start ! of the obstype number/name table for this sequence file. if (is_ascii) then read(ifile, *) header @@ -926,7 +953,7 @@ write(*, *) ' ', obs_type_info(i)%index, trim(obs_type_info(i)%name) end do -! Read the input as a string, convert to integers as appropriate +! Read the input as a string, convert to integers as appropriate read(*, '(A)') in ! If string is a positive or negative number, convert it to integer @@ -946,7 +973,7 @@ endif endif -! Make sure +! Make sure end function get_kind_from_menu @@ -954,11 +981,11 @@ function add_wind_names(my_names) !---------------------------------------------------------------------- -! Define/Append the 'horizontal wind' obs_kinds to supplant the list +! Define/Append the 'horizontal wind' obs_kinds to supplant the list ! of names for scalar observations in obs_kind_names() ! i.e. if there is a RADIOSONDE_U_WIND_COMPONENT and -! a RADIOSONDE_V_WIND_COMPONENT, there must be -! +! a RADIOSONDE_V_WIND_COMPONENT, there must be +! ! a RADIOSONDE_HORIZONTAL_WIND ! Replace calls to 'get_obs_kind_name' with variable 'my_obs_kind_names' !---------------------------------------------------------------------- @@ -984,7 +1011,7 @@ nwinds = 0 ! Copy all the known obs kinds to a local list that is SURELY too BIG -! as we find wind pairs, we insert the new name at the end of the known +! as we find wind pairs, we insert the new name at the end of the known ! names. do ivar = 1,max_obs_kinds @@ -1051,7 +1078,7 @@ if ( DEBUG ) write(*,*)'There are ',nwinds,' pairs of winds.' ! Now that we know how many wind pairs there are, we return the -! exact number and new array of observation kind names +! exact number and new array of observation kind names add_wind_names = max_obs_kinds + nwinds @@ -1079,7 +1106,7 @@ ! ! obstype1 The (specific) 'type' of a candidate observation ! obstype2 The (specific) 'type' of a candidate observation -! obskey The observation number (from the obs sequence file - +! obskey The observation number (from the obs sequence file - ! used for error messages only) ! all_obs_typenames The 'extended' list of observation types - declared ! by grok_observation_names() @@ -1132,7 +1159,7 @@ return endif -! Focus on getting the platform name +! Focus on getting the platform name ! There are only two viable wind component strings (see obs_def_mod.f90): ! '_?_WIND_COMPONENT' and '_?_10_METER_WIND' @@ -1158,7 +1185,7 @@ ! So now we have the platform name for one of the observations ! and that (1:indx1) defines the platform name in a matching scenario. -! str1(1:indx1) and str2(1:indx1) should be the wind name - +! str1(1:indx1) and str2(1:indx1) should be the wind name - ! 'RADIOSONDE_' or 'SHIP_' or 'AIREP_' or ... if ( str1(1:indx1) /= str2(1:indx1) ) then @@ -1182,7 +1209,7 @@ endif enddo MyKind -! If we have checked all the types and not found a match ... +! If we have checked all the types and not found a match ... if (.not. do_obs_form_pair ) then write( * ,*) trim(str1),' ',trim(str2) From nancy at ucar.edu Thu May 10 17:15:03 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Thu, 10 May 2012 17:15:03 -0600 Subject: [Dart-dev] [5741] DART/branches/development/obs_def/obs_def_tower_mod.f90: stub for flux observation operators in place Message-ID: Revision: 5741 Author: thoar Date: 2012-05-10 17:15:03 -0600 (Thu, 10 May 2012) Log Message: ----------- stub for flux observation operators in place Modified Paths: -------------- DART/branches/development/obs_def/obs_def_tower_mod.f90 -------------- next part -------------- Modified: DART/branches/development/obs_def/obs_def_tower_mod.f90 =================================================================== --- DART/branches/development/obs_def/obs_def_tower_mod.f90 2012-05-09 22:56:36 UTC (rev 5740) +++ DART/branches/development/obs_def/obs_def_tower_mod.f90 2012-05-10 23:15:03 UTC (rev 5741) @@ -15,16 +15,183 @@ !TOWER_SOIL_TEMPERATURE, KIND_TEMPERATURE, COMMON_CODE !TOWER_U_WIND_COMPONENT, KIND_U_WIND_COMPONENT, COMMON_CODE !TOWER_V_WIND_COMPONENT, KIND_V_WIND_COMPONENT, COMMON_CODE -!TOWER_LATENT_HEAT_FLUX, KIND_LATENT_HEAT_FLUX, COMMON_CODE -!TOWER_SENSIBLE_HEAT_FLUX, KIND_SENSIBLE_HEAT_FLUX, COMMON_CODE +!TOWER_LATENT_HEAT_FLUX, KIND_LATENT_HEAT_FLUX +!TOWER_SENSIBLE_HEAT_FLUX, KIND_SENSIBLE_HEAT_FLUX !TOWER_GLOBAL_RADIATION, KIND_RADIATION, COMMON_CODE -!TOWER_NETC_ECO_EXCHANGE, KIND_NET_CARBON_PRODUCTION, COMMON_CODE +!TOWER_NETC_ECO_EXCHANGE, KIND_NET_CARBON_PRODUCTION !TOWER_NET_CARBON_FLUX, KIND_NET_CARBON_FLUX, COMMON_CODE ! END DART PREPROCESS KIND LIST +!----------------------------------------------------------------------------- +! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE +! use obs_def_tower_mod, only : get_expected_latent_heat_flux +! use obs_def_tower_mod, only : get_expected_sensible_heat_flux +! use obs_def_tower_mod, only : get_expected_net_C_production +! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE +!----------------------------------------------------------------------------- + +!----------------------------------------------------------------------------- +! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF +! case(TOWER_LATENT_HEAT_FLUX) +! call get_expected_latent_heat_flux(state, state_time, ens_index, location, obs_def%key, obs_val, istatus) +! case(TOWER_SENSIBLE_HEAT_FLUX) +! call get_expected_sensible_heat_flux(state, state_time, ens_index, location, obs_def%key, obs_val, istatus) +! case(TOWER_NETC_ECO_EXCHANGE) +! call get_expected_net_C_production(state, state_time, ens_index, location, obs_def%key, obs_val, istatus) +! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF +!----------------------------------------------------------------------------- + +!----------------------------------------------------------------------------- +! BEGIN DART PREPROCESS READ_OBS_DEF +! END DART PREPROCESS READ_OBS_DEF +!----------------------------------------------------------------------------- + +!----------------------------------------------------------------------------- +! BEGIN DART PREPROCESS WRITE_OBS_DEF +! END DART PREPROCESS WRITE_OBS_DEF +!----------------------------------------------------------------------------- + +!----------------------------------------------------------------------------- +! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF +! END DART PREPROCESS INTERACTIVE_OBS_DEF +!----------------------------------------------------------------------------- + +!----------------------------------------------------------------------------- +! BEGIN DART PREPROCESS MODULE CODE +module obs_def_tower_mod + ! ! $URL$ ! $Id$ ! $Revision$ ! $Date$ +use types_mod, only : r8, missing_r8, PI, deg2rad +use location_mod, only : location_type +use time_manager_mod, only : time_type +use utilities_mod, only : register_module, E_ERR, error_handler + +implicit none +private + +public :: get_expected_latent_heat_flux, & + get_expected_sensible_heat_flux, & + get_expected_net_C_production + +! version controlled file description for error handling, do not edit +character(len=128), parameter :: & + source = "$URL$", & + revision = "$Revision$", & + revdate = "$Date$" + +logical :: module_initialized = .false. + +character(len=129) :: string1,string2,string3 + +contains + +!---------------------------------------------------------------------- +!---------------------------------------------------------------------- +! Start of executable routines +!---------------------------------------------------------------------- +!---------------------------------------------------------------------- + +subroutine initialize_module + +! Called once to set values and allocate space + +! integer :: iunit, io, rc + +! Prevent multiple calls from executing this code more than once. +if (module_initialized) return + +module_initialized = .true. + +! Log the version of this source file. +call register_module(source, revision, revdate) + +! ! Read the namelist entry. +! call find_namelist_in_file("input.nml", "obs_def_tower_nml", iunit) +! read(iunit, nml = obs_def_ocean_nml, iostat = io) +! call check_namelist_read(iunit, io, "obs_def_ocean_nml") + +! ! Record the namelist values used for the run ... +! if (do_nml_file()) write(nmlfileunit, nml=obs_def_ocean_nml) +! if (do_nml_term()) write( * , nml=obs_def_ocean_nml) + +end subroutine initialize_module + + +subroutine get_expected_latent_heat_flux(state, state_time, ens_index, location, obs_key, obs_val, istatus) +! the routine must return values for: +! obs_val -- the computed forward operator value +! istatus -- return code: 0=ok, > 0 is error, < 0 reserved for system use + +real(r8), intent(in) :: state(:) +type(time_type), intent(in) :: state_time +integer, intent(in) :: ens_index +type(location_type), intent(in) :: location +integer, intent(in) :: obs_key +real(r8), intent(out) :: obs_val +integer, intent(out) :: istatus + +obs_val = MISSING_R8 +istatus = 1 + +call error_handler(E_ERR, 'get_expected_latent_heat_flux', & + 'not implemented yet.', & + source, revision, revdate) + +end subroutine get_expected_latent_heat_flux + + + +subroutine get_expected_sensible_heat_flux(state, state_time, ens_index, location, obs_key, obs_val, istatus) +! the routine must return values for: +! obs_val -- the computed forward operator value +! istatus -- return code: 0=ok, > 0 is error, < 0 reserved for system use +real(r8), intent(in) :: state(:) +type(time_type), intent(in) :: state_time +integer, intent(in) :: ens_index +type(location_type), intent(in) :: location +integer, intent(in) :: obs_key +real(r8), intent(out) :: obs_val +integer, intent(out) :: istatus + +obs_val = MISSING_R8 +istatus = 1 + +call error_handler(E_ERR, 'get_expected_sensible_heat_flux', & + 'not implemented yet.', & + source, revision, revdate) + +end subroutine get_expected_sensible_heat_flux + + +subroutine get_expected_net_C_production(state, state_time, ens_index, location, obs_key, obs_val, istatus) +! the routine must return values for: +! obs_val -- the computed forward operator value +! istatus -- return code: 0=ok, > 0 is error, < 0 reserved for system use +real(r8), intent(in) :: state(:) +type(time_type), intent(in) :: state_time +integer, intent(in) :: ens_index +type(location_type), intent(in) :: location +integer, intent(in) :: obs_key +real(r8), intent(out) :: obs_val +integer, intent(out) :: istatus + +obs_val = MISSING_R8 +istatus = 1 + +call error_handler(E_ERR, 'get_expected_net_C_production', & + 'not implemented yet.', & + source, revision, revdate) + +end subroutine get_expected_net_C_production + + + +end module obs_def_tower_mod + +! END DART PREPROCESS MODULE CODE +!----------------------------------------------------------------------------- From nancy at ucar.edu Fri May 11 08:27:07 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Fri, 11 May 2012 08:27:07 -0600 Subject: [Dart-dev] [5742] DART/branches/development/obs_def/obs_def_tower_mod.f90: Better stubs for the extended observation support. Message-ID: Revision: 5742 Author: thoar Date: 2012-05-11 08:27:07 -0600 (Fri, 11 May 2012) Log Message: ----------- Better stubs for the extended observation support. At some point, these should be implemented for the tower observations and we can tag the obs with metadata like soil type, vegetation type, plant functional type ... etc. Will allow for more accurate observation operators. Modified Paths: -------------- DART/branches/development/obs_def/obs_def_tower_mod.f90 -------------- next part -------------- Modified: DART/branches/development/obs_def/obs_def_tower_mod.f90 =================================================================== --- DART/branches/development/obs_def/obs_def_tower_mod.f90 2012-05-10 23:15:03 UTC (rev 5741) +++ DART/branches/development/obs_def/obs_def_tower_mod.f90 2012-05-11 14:27:07 UTC (rev 5742) @@ -43,16 +43,22 @@ !----------------------------------------------------------------------------- ! BEGIN DART PREPROCESS READ_OBS_DEF +! case(TOWER_LATENT_HEAT_FLUX,TOWER_SENSIBLE_HEAT_FLUX,TOWER_NETC_ECO_EXCHANGE) +! continue ! END DART PREPROCESS READ_OBS_DEF !----------------------------------------------------------------------------- !----------------------------------------------------------------------------- ! BEGIN DART PREPROCESS WRITE_OBS_DEF +! case(TOWER_LATENT_HEAT_FLUX,TOWER_SENSIBLE_HEAT_FLUX,TOWER_NETC_ECO_EXCHANGE) +! continue ! END DART PREPROCESS WRITE_OBS_DEF !----------------------------------------------------------------------------- !----------------------------------------------------------------------------- ! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF +! case(TOWER_LATENT_HEAT_FLUX,TOWER_SENSIBLE_HEAT_FLUX,TOWER_NETC_ECO_EXCHANGE) +! continue ! END DART PREPROCESS INTERACTIVE_OBS_DEF !----------------------------------------------------------------------------- From nancy at ucar.edu Thu May 31 16:47:55 2012 From: nancy at ucar.edu (nancy at ucar.edu) Date: Thu, 31 May 2012 16:47:55 -0600 Subject: [Dart-dev] [5743] DART/branches/development: This is a uniform PV two-surface QG+1 spectral model contributed Message-ID: Revision: 5743 Author: nancy Date: 2012-05-31 16:47:55 -0600 (Thu, 31 May 2012) Log Message: ----------- This is a uniform PV two-surface QG+1 spectral model contributed by Rahul Mahajan, based on a model from Greg Hakim. see the model_description file for an important note about a change needed in the obs_model_mod.f90 code. rahul also contributed updated matlab diagnostic files with cases for the 'sqg' model, but i haven't merged them yet with the most recent changes tim made in the diags. i'll commit those as soon as i can. Added Paths: ----------- DART/branches/development/models/sqg/ DART/branches/development/models/sqg/fft.f90 DART/branches/development/models/sqg/model_description DART/branches/development/models/sqg/model_mod.f90 DART/branches/development/models/sqg/spectral_mod.f90 DART/branches/development/models/sqg/sqg.f90 DART/branches/development/models/sqg/sqg_mod.f90 DART/branches/development/models/sqg/work/ DART/branches/development/models/sqg/work/input.nml DART/branches/development/models/sqg/work/mkmf_closest_member_tool DART/branches/development/models/sqg/work/mkmf_create_fixed_network_seq DART/branches/development/models/sqg/work/mkmf_create_obs_sequence DART/branches/development/models/sqg/work/mkmf_filter DART/branches/development/models/sqg/work/mkmf_integrate_model DART/branches/development/models/sqg/work/mkmf_obs_diag DART/branches/development/models/sqg/work/mkmf_obs_seq_to_netcdf DART/branches/development/models/sqg/work/mkmf_obs_sequence_tool DART/branches/development/models/sqg/work/mkmf_perfect_model_obs DART/branches/development/models/sqg/work/mkmf_preprocess DART/branches/development/models/sqg/work/mkmf_restart_file_tool DART/branches/development/models/sqg/work/mkmf_sqg DART/branches/development/models/sqg/work/mkmf_wakeup_filter DART/branches/development/models/sqg/work/mkmf_write_sqg_restart DART/branches/development/models/sqg/work/obs_network.py DART/branches/development/models/sqg/work/obs_seq.in DART/branches/development/models/sqg/work/obs_seq.out DART/branches/development/models/sqg/work/path_names_closest_member_tool DART/branches/development/models/sqg/work/path_names_create_fixed_network_seq DART/branches/development/models/sqg/work/path_names_create_obs_sequence DART/branches/development/models/sqg/work/path_names_filter DART/branches/development/models/sqg/work/path_names_integrate_model DART/branches/development/models/sqg/work/path_names_obs_diag DART/branches/development/models/sqg/work/path_names_obs_seq_to_netcdf DART/branches/development/models/sqg/work/path_names_obs_sequence_tool DART/branches/development/models/sqg/work/path_names_perfect_model_obs DART/branches/development/models/sqg/work/path_names_preprocess DART/branches/development/models/sqg/work/path_names_restart_file_tool DART/branches/development/models/sqg/work/path_names_sqg DART/branches/development/models/sqg/work/path_names_wakeup_filter DART/branches/development/models/sqg/work/path_names_write_sqg_restart DART/branches/development/models/sqg/work/quickbuild.csh DART/branches/development/models/sqg/work/sqgRestart.nc DART/branches/development/models/sqg/write_sqg_restart.f90 DART/branches/development/obs_def/obs_def_sqg_mod.f90 -------------- next part -------------- Added: DART/branches/development/models/sqg/fft.f90 =================================================================== --- DART/branches/development/models/sqg/fft.f90 (rev 0) +++ DART/branches/development/models/sqg/fft.f90 2012-05-31 22:47:55 UTC (rev 5743) @@ -0,0 +1,563 @@ +! =========================================================== +! +! $URL$ +! $Id$ +! $Revision$ +! $Date$ +! =========================================================== + +! ====================================================================== +! NIST Guide to Available Math Software. +! Source for module FFT from package GO. +! Retrieved from NETLIB on Wed Jul 5 11:50:07 1995. +! ====================================================================== + + subroutine fft(a,b,ntot,n,nspan,isn) + +! multivariate complex fourier transform, computed in place +! using mixed-radix fast fourier transform algorithm. +! by r. c. singleton, stanford research institute, sept. 1968 +! arrays a and b originally hold the real and imaginary +! components of the data, and return the real and +! imaginary components of the resulting fourier coefficients. +! multivariate data is indexed according to the fortran +! array element successor function, without limit +! on the number of implied multiple subscripts. +! the subroutine is called once for each variate. +! the calls for a multivariate transform may be in any order. +! ntot is the total number of complex data values. +! n is the dimension of the current variable. +! nspan/n is the spacing of consecutive data values +! while indexing the current variable. +! the sign of isn determines the sign of the complex +! exponential, and the magnitude of isn is normally one. +! a tri-variate transform with a(n1,n2,n3), b(n1,n2,n3) +! is computed by +! call fft(a,b,n1*n2*n3,n1,n1,1) +! call fft(a,b,n1*n2*n3,n2,n1*n2,1) +! call fft(a,b,n1*n2*n3,n3,n1*n2*n3,1) +! for a single-variate transform, +! ntot = n = nspan = (number of complex data values), e.g. +! call fft(a,b,n,n,n,1) +! the data can alternatively be stored in a single complex array c +! in standard fortran fashion, i.e. alternating real and imaginary +! parts. then with most fortran compilers, the complex array c can +! be equivalenced to a real array a, the magnitude of isn changed +! to two to give correct indexing increment, and a(1) and a(2) used +! to pass the initial addresses for the sequences of real and +! imaginary values, e.g. +! complex c(ntot) +! real a(2*ntot) +! equivalence (c(1),a(1)) +! call fft(a(1),a(2),ntot,n,nspan,2) +! arrays at(maxf), ck(maxf), bt(maxf), sk(maxf), and np(maxp) +! are used for temporary storage. if the available storage +! is insufficient, the program is terminated by a stop. +! maxf must be .ge. the maximum prime factor of n. +! maxp must be .gt. the number of prime factors of n. +! in addition, if the square-free portion k of n has two or +! more prime factors, then maxp must be .ge. k-1. +! dimension a(1),b(1) + dimension a(*),b(*) +! array storage in nfac for a maximum of 15 prime factors of n. +! if n has more than one square-free factor, the product of the +! square-free factors must be .le. 210 + dimension nfac(101),np(209) +! array storage for maximum prime factor of 23 + dimension at(53),ck(53),bt(53),sk(53) + equivalence (i,ii) +! the following two constants should agree with the array dimensions. + maxp=209 + if(n .lt. 2) return + inc=isn + c72=0.30901699437494742 + s72=0.95105651629515357 + s120=0.86602540378443865 + rad=6.2831853071796 + if(isn .ge. 0) go to 10 + s72=-s72 + s120=-s120 + rad=-rad + inc=-inc + 10 nt=inc*ntot + ks=inc*nspan + kspan=ks + nn=nt-inc + jc=ks/n + radf=rad*float(jc)*0.5 + i=0 + jf=0 +! determine the factors of n + m=0 + k=n + go to 20 + 15 m=m+1 + nfac(m)=4 + k=k/16 + 20 if(k-(k/16)*16 .eq. 0) go to 15 + j=3 + jj=9 + go to 30 + 25 m=m+1 + nfac(m)=j + k=k/jj + 30 if(mod(k,jj) .eq. 0) go to 25 + j=j+2 + jj=j**2 + if(jj .le. k) go to 30 + if(k .gt. 4) go to 40 + kt=m + nfac(m+1)=k + if(k .ne. 1) m=m+1 + go to 80 + 40 if(k-(k/4)*4 .ne. 0) go to 50 + m=m+1 + nfac(m)=2 + k=k/4 + 50 kt=m + j=2 + 60 if(mod(k,j) .ne. 0) go to 70 + m=m+1 + nfac(m)=j + k=k/j + 70 j=((j+1)/2)*2+1 + if(j .le. k) go to 60 + 80 if(kt .eq. 0) go to 100 + j=kt + 90 m=m+1 + nfac(m)=nfac(j) + j=j-1 + if(j .ne. 0) go to 90 +! compute fourier transform + 100 sd=radf/float(kspan) + cd=2.0*sin(sd)**2 + sd=sin(sd+sd) + kk=1 + i=i+1 + if(nfac(i) .ne. 2) go to 400 +! transform for factor of 2 (including rotation factor) + kspan=kspan/2 + k1=kspan+2 + 210 k2=kk+kspan + ak=a(k2) + bk=b(k2) + a(k2)=a(kk)-ak + b(k2)=b(kk)-bk + a(kk)=a(kk)+ak + b(kk)=b(kk)+bk + kk=k2+kspan + if(kk .le. nn) go to 210 + kk=kk-nn + if(kk .le. jc) go to 210 + if(kk .gt. kspan) go to 800 + 220 c1=1.0-cd + s1=sd + 230 k2=kk+kspan + ak=a(kk)-a(k2) + bk=b(kk)-b(k2) + a(kk)=a(kk)+a(k2) + b(kk)=b(kk)+b(k2) + a(k2)=c1*ak-s1*bk + b(k2)=s1*ak+c1*bk + kk=k2+kspan + if(kk .lt. nt) go to 230 + k2=kk-nt + c1=-c1 + kk=k1-k2 + if(kk .gt. k2) go to 230 + ak=c1-(cd*c1+sd*s1) + s1=(sd*c1-cd*s1)+s1 + c1=2.0-(ak**2+s1**2) + s1=c1*s1 + c1=c1*ak + kk=kk+jc + if(kk .lt. k2) go to 230 + k1=k1+inc+inc + kk=(k1-kspan)/2+jc + if(kk .le. jc+jc) go to 220 + go to 100 +! transform for factor of 3 (optional code) + 320 k1=kk+kspan + k2=k1+kspan + ak=a(kk) + bk=b(kk) + aj=a(k1)+a(k2) + bj=b(k1)+b(k2) + a(kk)=ak+aj + b(kk)=bk+bj + ak=-0.5*aj+ak + bk=-0.5*bj+bk + aj=(a(k1)-a(k2))*s120 + bj=(b(k1)-b(k2))*s120 + a(k1)=ak-bj + b(k1)=bk+aj + a(k2)=ak+bj + b(k2)=bk-aj + kk=k2+kspan + if(kk .lt. nn) go to 320 + kk=kk-nn + if(kk .le. kspan) go to 320 + go to 700 +! transform for factor of 4 + 400 if(nfac(i) .ne. 4) go to 600 + kspnn=kspan + kspan=kspan/4 + 410 c1=1.0 + s1=0 + 420 k1=kk+kspan + k2=k1+kspan + k3=k2+kspan + akp=a(kk)+a(k2) + akm=a(kk)-a(k2) + ajp=a(k1)+a(k3) + ajm=a(k1)-a(k3) + a(kk)=akp+ajp + ajp=akp-ajp + bkp=b(kk)+b(k2) + bkm=b(kk)-b(k2) + bjp=b(k1)+b(k3) + bjm=b(k1)-b(k3) + b(kk)=bkp+bjp + bjp=bkp-bjp + if(isn .lt. 0) go to 450 + akp=akm-bjm + akm=akm+bjm + bkp=bkm+ajm + bkm=bkm-ajm + if(s1 .eq. 0) go to 460 + 430 a(k1)=akp*c1-bkp*s1 + b(k1)=akp*s1+bkp*c1 + a(k2)=ajp*c2-bjp*s2 + b(k2)=ajp*s2+bjp*c2 + a(k3)=akm*c3-bkm*s3 + b(k3)=akm*s3+bkm*c3 + kk=k3+kspan + if(kk .le. nt) go to 420 + 440 c2=c1-(cd*c1+sd*s1) + s1=(sd*c1-cd*s1)+s1 + c1=2.0-(c2**2+s1**2) + s1=c1*s1 + c1=c1*c2 + c2=c1**2-s1**2 + s2=2.0*c1*s1 + c3=c2*c1-s2*s1 + s3=c2*s1+s2*c1 + kk=kk-nt+jc + if(kk .le. kspan) go to 420 + kk=kk-kspan+inc + if(kk .le. jc) go to 410 + if(kspan .eq. jc) go to 800 + go to 100 + 450 akp=akm+bjm + akm=akm-bjm + bkp=bkm-ajm + bkm=bkm+ajm + if(s1 .ne. 0) go to 430 + 460 a(k1)=akp + b(k1)=bkp + a(k2)=ajp + b(k2)=bjp + a(k3)=akm + b(k3)=bkm + kk=k3+kspan + if(kk .le. nt) go to 420 + go to 440 +! transform for factor of 5 (optional code) + 510 c2=c72**2-s72**2 + s2=2.0*c72*s72 + 520 k1=kk+kspan + k2=k1+kspan + k3=k2+kspan + k4=k3+kspan + akp=a(k1)+a(k4) + akm=a(k1)-a(k4) + bkp=b(k1)+b(k4) + bkm=b(k1)-b(k4) + ajp=a(k2)+a(k3) + ajm=a(k2)-a(k3) + bjp=b(k2)+b(k3) + bjm=b(k2)-b(k3) + aa=a(kk) + bb=b(kk) + a(kk)=aa+akp+ajp + b(kk)=bb+bkp+bjp + ak=akp*c72+ajp*c2+aa + bk=bkp*c72+bjp*c2+bb + aj=akm*s72+ajm*s2 + bj=bkm*s72+bjm*s2 + a(k1)=ak-bj + a(k4)=ak+bj + b(k1)=bk+aj + b(k4)=bk-aj + ak=akp*c2+ajp*c72+aa + bk=bkp*c2+bjp*c72+bb + aj=akm*s2-ajm*s72 + bj=bkm*s2-bjm*s72 + a(k2)=ak-bj + a(k3)=ak+bj + b(k2)=bk+aj + b(k3)=bk-aj + kk=k4+kspan + if(kk .lt. nn) go to 520 + kk=kk-nn + if(kk .le. kspan) go to 520 + go to 700 +! transform for odd factors + 600 k=nfac(i) + kspnn=kspan + kspan=kspan/k + if(k .eq. 3) go to 320 + if(k .eq. 5) go to 510 + if(k .eq. jf) go to 640 + jf=k + s1=rad/float(k) + c1=cos(s1) + s1=sin(s1) + if(jf .gt. maxf) go to 998 + ck(jf)=1.0 + sk(jf)=0.0 + j=1 + 630 ck(j)=ck(k)*c1+sk(k)*s1 + sk(j)=ck(k)*s1-sk(k)*c1 + k=k-1 + ck(k)=ck(j) + sk(k)=-sk(j) + j=j+1 + if(j .lt. k) go to 630 + 640 k1=kk + k2=kk+kspnn + aa=a(kk) + bb=b(kk) + ak=aa + bk=bb + j=1 + k1=k1+kspan + 650 k2=k2-kspan + j=j+1 + at(j)=a(k1)+a(k2) + ak=at(j)+ak + bt(j)=b(k1)+b(k2) + bk=bt(j)+bk + j=j+1 + at(j)=a(k1)-a(k2) + bt(j)=b(k1)-b(k2) + k1=k1+kspan + if(k1 .lt. k2) go to 650 + a(kk)=ak + b(kk)=bk + k1=kk + k2=kk+kspnn + j=1 + 660 k1=k1+kspan + k2=k2-kspan + jj=j + ak=aa + bk=bb + aj=0.0 + bj=0.0 + k=1 + 670 k=k+1 + ak=at(k)*ck(jj)+ak + bk=bt(k)*ck(jj)+bk + k=k+1 + aj=at(k)*sk(jj)+aj + bj=bt(k)*sk(jj)+bj + jj=jj+j + if(jj .gt. jf) jj=jj-jf + if(k .lt. jf) go to 670 + k=jf-j + a(k1)=ak-bj + b(k1)=bk+aj + a(k2)=ak+bj + b(k2)=bk-aj + j=j+1 + if(j .lt. k) go to 660 + kk=kk+kspnn + if(kk .le. nn) go to 640 + kk=kk-nn + if(kk .le. kspan) go to 640 +! multiply by rotation factor (except for factors of 2 and 4) + 700 if(i .eq. m) go to 800 + kk=jc+1 + 710 c2=1.0-cd + s1=sd + 720 c1=c2 + s2=s1 + kk=kk+kspan + 730 ak=a(kk) + a(kk)=c2*ak-s2*b(kk) + b(kk)=s2*ak+c2*b(kk) + kk=kk+kspnn + if(kk .le. nt) go to 730 + ak=s1*s2 + s2=s1*c2+c1*s2 + c2=c1*c2-ak + kk=kk-nt+kspan + if(kk .le. kspnn) go to 730 + c2=c1-(cd*c1+sd*s1) + s1=s1+(sd*c1-cd*s1) + c1=2.0-(c2**2+s1**2) + s1=c1*s1 + c2=c1*c2 + kk=kk-kspnn+jc + if(kk .le. kspan) go to 720 + kk=kk-kspan+jc+inc + if(kk .le. jc+jc) go to 710 + go to 100 +! permute the results to normal order---done in two stages +! permutation for square factors of n + 800 np(1)=ks + if(kt .eq. 0) go to 890 + k=kt+kt+1 + if(m .lt. k) k=k-1 + j=1 + np(k+1)=jc + 810 np(j+1)=np(j)/nfac(j) + np(k)=np(k+1)*nfac(j) + j=j+1 + k=k-1 + if(j .lt. k) go to 810 + k3=np(k+1) + kspan=np(2) + kk=jc+1 + k2=kspan+1 + j=1 + if(n .ne. ntot) go to 850 +! permutation for single-variate transform (optional code) + 820 ak=a(kk) + a(kk)=a(k2) + a(k2)=ak + bk=b(kk) + b(kk)=b(k2) + b(k2)=bk + kk=kk+inc + k2=kspan+k2 + if(k2 .lt. ks) go to 820 + 830 k2=k2-np(j) + j=j+1 + k2=np(j+1)+k2 + if(k2 .gt. np(j)) go to 830 + j=1 + 840 if(kk .lt. k2) go to 820 + kk=kk+inc + k2=kspan+k2 + if(k2 .lt. ks) go to 840 + if(kk .lt. ks) go to 830 + jc=k3 + go to 890 +! permutation for multivariate transform + 850 k=kk+jc + 860 ak=a(kk) + a(kk)=a(k2) + a(k2)=ak + bk=b(kk) + b(kk)=b(k2) + b(k2)=bk + kk=kk+inc + k2=k2+inc + if(kk .lt. k) go to 860 + kk=kk+ks-jc + k2=k2+ks-jc + if(kk .lt. nt) go to 850 + k2=k2-nt+kspan + kk=kk-nt+jc + if(k2 .lt. ks) go to 850 + 870 k2=k2-np(j) + j=j+1 + k2=np(j+1)+k2 + if(k2 .gt. np(j)) go to 870 + j=1 + 880 if(kk .lt. k2) go to 850 + kk=kk+jc + k2=kspan+k2 + if(k2 .lt. ks) go to 880 + if(kk .lt. ks) go to 870 + jc=k3 + 890 if(2*kt+1 .ge. m) return + kspnn=np(kt+1) +! permutation for square-free factors of n + j=m-kt + nfac(j+1)=1 + 900 nfac(j)=nfac(j)*nfac(j+1) + j=j-1 + if(j .ne. kt) go to 900 + kt=kt+1 + nn=nfac(kt)-1 + if(nn .gt. maxp) go to 998 + jj=0 + j=0 + go to 906 + 902 jj=jj-k2 + k2=kk + k=k+1 + kk=nfac(k) + 904 jj=kk+jj + if(jj .ge. k2) go to 902 + np(j)=jj + 906 k2=nfac(kt) + k=kt+1 + kk=nfac(k) + j=j+1 + if(j .le. nn) go to 904 +! determine the permutation cycles of length greater than 1 + j=0 + go to 914 + 910 k=kk + kk=np(k) + np(k)=-kk + if(kk .ne. j) go to 910 + k3=kk + 914 j=j+1 + kk=np(j) + if(kk .lt. 0) go to 914 + if(kk .ne. j) go to 910 + np(j)=-j + if(j .ne. nn) go to 914 + maxf=inc*maxf +! reorder a and b, following the permutation cycles + go to 950 + 924 j=j-1 + if(np(j) .lt. 0) go to 924 + jj=jc + 926 kspan=jj + if(jj .gt. maxf) kspan=maxf + jj=jj-kspan + k=np(j) + kk=jc*k+ii+jj + k1=kk+kspan + k2=0 + 928 k2=k2+1 + at(k2)=a(k1) + bt(k2)=b(k1) + k1=k1-inc + if(k1 .ne. kk) go to 928 + 932 k1=kk+kspan + k2=k1-jc*(k+np(k)) + k=-np(k) + 936 a(k1)=a(k2) + b(k1)=b(k2) + k1=k1-inc + k2=k2-inc + if(k1 .ne. kk) go to 936 + kk=k2 + if(k .ne. j) go to 932 + k1=kk+kspan + k2=0 + 940 k2=k2+1 + a(k1)=at(k2) + b(k1)=bt(k2) + k1=k1-inc + if(k1 .ne. kk) go to 940 + if(jj .ne. 0) go to 926 + if(j .ne. 1) go to 924 + 950 j=k3+1 + nt=nt-kspnn + ii=nt-inc+1 + if(nt .ge. 0) go to 924 + return +! error finish, insufficient array storage + 998 isn=0 + print*,'array bounds exceeded within subroutine fft' + + stop + end Property changes on: DART/branches/development/models/sqg/fft.f90 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Rev Author HeadURL Id Added: svn:eol-style + native Added: DART/branches/development/models/sqg/model_description =================================================================== --- DART/branches/development/models/sqg/model_description (rev 0) +++ DART/branches/development/models/sqg/model_description 2012-05-31 22:47:55 UTC (rev 5743) @@ -0,0 +1,42 @@ + +This is a uniform PV two-surface QG+1 spectral model contributed +by Rahul Majahan. + +The underlying model is described in: +Hakim, Gregory J., 2000: Role of Nonmodal Growth and Nonlinearity in +Cyclogenesis Initial-Value Problems. J. Atmos. Sci., 57, 2951?2967. + + +NOTE: + +This model counts on a non-standard interface to the obs_model_mod.f90 +code in DART/obs_model. To compile and run this model, make the +following (non-backwards-compatible) two changes: + + +1: + + !------------- Block for subroutine callable adv_1step interface ----------- + if(async == 0) then + + do while(ens_handle%time(i) < target_time) + call adv_1step(ens_handle%vars(:, i), ens_handle%time(i)) + ens_handle%time(i) = ens_handle%time(i) + time_step + end do + +! start of new section + else if(async == 1) then + + call adv_1step(ens_handle%vars(:, i), ens_handle%time(i), target_time) + ens_handle%time(i) = target_time +! end of new section + + !-------------- End single subroutine callable adv_1step interface --------- + +and 2: + +! Following is for async options that use shell to advance model +SHELL_ADVANCE_METHODS: if(async > 1) then + +! changed from: if(async /= 0) then + Added: DART/branches/development/models/sqg/model_mod.f90 =================================================================== --- DART/branches/development/models/sqg/model_mod.f90 (rev 0) +++ DART/branches/development/models/sqg/model_mod.f90 2012-05-31 22:47:55 UTC (rev 5743) @@ -0,0 +1,1057 @@ + +! DART software - Copyright 2004 - 2011 UCAR. This open source software is +! provided by UCAR, "as is", without charge, subject to all terms of use at +! http://www.image.ucar.edu/DAReS/DART/DART_download + +module model_mod + +!======================================================================== +! +! $URL$ +! $Id$ +! $Revision$ +! $Date$ +!======================================================================== + +!======================================================================== +! Assimilation interface for: +! Uniform-PV two-surface QG+1 model in spectral form (Hakim 2000) +!======================================================================== + +!================= m o d u l e i n f o r m a t i o n ================== + +use types_mod, only : r8, MISSING_R8 +use time_manager_mod, only : time_type, set_time, get_time, & + operator(<), operator(+) +use location_mod, only : location_type, get_close_maxdist_init, & + get_close_obs_init, get_close_obs, set_location, & + get_location, set_location_missing +use utilities_mod, only : register_module, error_handler, nc_check, & + E_ERR, E_MSG, logfileunit, get_unit, close_file, & + dump_unit_attributes, & + nmlfileunit, do_output, do_nml_file, do_nml_term, & + find_namelist_in_file, check_namelist_read +use obs_kind_mod, only : KIND_POTENTIAL_TEMPERATURE +use spectral_mod +use sqg_mod, only : diffusion, init, init_jet, terrain, invert, advect, & + tadv, xy_to_sp, sp_to_xy, d_setup, ft_2d, norm + +!======================================================================== + +implicit none + +private + +public :: get_model_size, & + adv_1step, & + get_state_meta_data, & + model_interpolate, & + get_model_time_step, & + end_model, & + static_init_model, & + init_time, & + init_conditions, & + nc_write_model_atts, & + nc_write_model_vars, & + pert_model_state, & + get_close_maxdist_init, & + get_close_obs_init, & + get_close_obs, & + ens_mean_for_model + +! public subroutines / functions +public :: sqg_to_dart, & + dart_to_sqg, & + get_model_static_data + +! public types +public :: model_static + +! version controlled file description for error handling, do not edit +character(len=128), parameter :: & + source = "$URL$", & + revision = "$Revision$", & + revdate = "$Date$" + +!--------------------------------------------------------------- +! Namelist with default values + +logical :: output_state_vector = .false. +real(r8) :: channel_center = 45.0_r8 +real(r8) :: channel_width = 40.0_r8 +logical :: debug = .false. +namelist /model_nml/ output_state_vector, & + channel_center, channel_width, & + debug + +real, dimension(mmax,nmax), parameter :: Rblank = 0.0 +complex, dimension(mmax,nmax), parameter :: Cblank = 0.0 + +integer, parameter :: model_size = 2 * (2*kmax) * (2*lmax) + +! Define the location of the state variables in module storage +type(location_type), allocatable :: state_loc(:) + +type(time_type) :: time_step +character(len=129) :: errstring + +type model_static + logical :: top, bot + real :: dco, lam + complex, allocatable, dimension(:,:) :: thbB, thbT + real, allocatable, dimension(:,:) :: thbyB, thbyT, ulinB, ulinT + real, allocatable, dimension(:,:) :: hx, hy, hu, hv + real(r8), allocatable, dimension(:) :: lons, lats, levs +end type model_static + +type(model_static) :: sqg_static + +!======================================================================== + +contains + +!======================================================================== + +subroutine static_init_model() +!----------------------------- +! Initializes class data for surface quasigeostrophy model +! (all the stuff that needs to be done once.) + +integer :: iunit, io + +integer :: i, lev_index, lat_index, lon_index +real(r8) :: lon, lat, lev + +! Print module information to log file and stdout. +call register_module(source, revision, revdate) + +! This is where you would read a namelist, for example. +call find_namelist_in_file("input.nml", "model_nml", iunit) +read(iunit, nml = model_nml, iostat = io) +call check_namelist_read(iunit, io, "model_nml") + +! Record the namelist values used for the run ... +if (do_nml_file()) write(nmlfileunit, nml=model_nml) +if (do_nml_term()) write( * , nml=model_nml) + +! evenly spaced longitudes, latitudes and two levels +allocate( sqg_static%lons(2*kmax) ) +allocate( sqg_static%lats(2*lmax) ) +allocate( sqg_static%levs(2 ) ) +do i = 1, 2*kmax + sqg_static%lons(i) = 360.0*(i-1.0)/(2*kmax) +enddo +! channel is centered about "channel_center" and has a width of "channel_width" +do i = 1, 2*lmax + sqg_static%lats(i) = channel_center + channel_width * (real(i,r8)/(2*lmax) - 0.5) +enddo +do i = 1, 2 + sqg_static%levs(i) = i +enddo + +! allocate storage for locations +allocate( state_loc(model_size) ) +do i = 1, model_size + lev_index = (i-1) / ((2*lmax)*(2*kmax)) + 1 + lat_index = ((i-1) - ((lev_index-1)*(2*lmax)*(2*kmax))) / (2*kmax) + 1 + lon_index = (i-1) - ((lev_index-1)*(2*lmax)*(2*kmax)) - ((lat_index-1)*(2*kmax)) + 1 + + lev = sqg_static%levs(lev_index) + lat = sqg_static%lats(lat_index) + lon = sqg_static%lons(lon_index) + + ! With the location module ... you specify that the + ! vertical coordinate is a 'level' by 'which_vert' == 1 + state_loc(i) = set_location(lon, lat, lev, 1) +enddo + +! get dimensional model time-step, +! follow non-dimensionalization conversion for sQG (Mahajan & Hakim 2011, Table 1) +! dTs = (Ls/Us) * dt ; Ls = 1000 km = 1e6 m ; Us = 30 m/s +time_step = set_time(int((1e6/30)*dt), 0) + +! initialize derivative operators in the model +call d_setup() + +! initialize diffusion coefficient +call diffusion(sqg_static%dco) + +! advection flags +if ( (model .eq. 0) .or. (model .eq. 1) ) then ! 2D or 2sQG + sqg_static%top = .true.; sqg_static%bot = .true. +elseif ( model .eq. 2 ) then ! tropo sQG + sqg_static%top = .true.; sqg_static%bot = .false. +elseif ( (model .eq. 3) .or. (model .eq. 0) ) then ! surface sQG + sqg_static%top = .false.; sqg_static%bot = .true. +elseif ( model .eq. 4 ) then ! tropo HsQG + sqg_static%top = .true.; sqg_static%bot = .false. +endif +!if (maxval(abs(thxyT)) .lt. 1.e-5) sqg_static%top = .false. +!if (maxval(abs(thxyB)) .lt. 1.e-5) sqg_static%bot = .false. + +! initialize Hoskins-West jet +allocate(sqg_static%thbB(2*kmax,2*lmax)) ; allocate(sqg_static%thbT(2*kmax,2*lmax)) +allocate(sqg_static%thbyB(mmax,nmax)) ; allocate(sqg_static%thbyT(mmax,nmax)) +allocate(sqg_static%ulinB(mmax,nmax)) ; allocate(sqg_static%ulinT(mmax,nmax)) +if ( hw ) then + + call init_jet(sqg_static%thbB, sqg_static%thbT, & + sqg_static%thbyB, sqg_static%thbyT, & + sqg_static%ulinB, sqg_static%ulinT, & + sqg_static%lam) + + ! barotropic wind (Ross = 0!) + sqg_static%ulinB = sqg_static%ulinB + 0.0 + sqg_static%ulinT = sqg_static%ulinT - 0.0 * H * sqg_static%lam + +else + + sqg_static%thbB = 0.0 ; sqg_static%thbT = 0.0 + sqg_static%thbyB = 0.0 ; sqg_static%thbyT = 0.0 + sqg_static%ulinB = 0.0 ; sqg_static%ulinT = 0.0 + sqg_static%lam = 0.0 + +endif + +! initialize terrain +allocate(sqg_static%hx(mmax,nmax)) ; allocate(sqg_static%hy(mmax,nmax)) +allocate(sqg_static%hu(mmax,nmax)) ; allocate(sqg_static%hv(mmax,nmax)) +if ( (iterr) .and. (Ross .eq. 0.0) ) then + call terrain(sqg_static%hx, sqg_static%hy, & + sqg_static%hu, sqg_static%hv) +else + sqg_static%hx = 0.0 ; sqg_static%hy = 0.0 + sqg_static%hu = 0.0 ; sqg_static%hv = 0.0 +endif + +end subroutine static_init_model + +!======================================================================== + +subroutine init_conditions(x) +!---------------------------- +! read initial conditions from a file, +! must only contain perturbation theta + +real(r8), intent(out) :: x(:) + +integer :: j +complex, allocatable, dimension(:,:) :: thspB, thspT +real, allocatable, dimension(:,:) :: thxyB, thxyT +real, allocatable, dimension(:,:,:) :: theta + +! initialize the theta fields: +allocate(thxyB(2*kmax,2*lmax)) ; allocate(thxyT(2*kmax,2*lmax)) +call init('sqgInput.nc',thxyB,thxyT) + +! first add base-state jet: +if ( hw ) then + + allocate(thspB(2*kmax,2*lmax)) ; allocate(thspT(2*kmax,2*lmax)) + + ! map into spectral space at the same resolution: + call xy_to_sp(cmplx(thxyB,0.0),thspB,2*kmax,2*lmax,kmax,lmax) + call xy_to_sp(cmplx(thxyT,0.0),thspT,2*kmax,2*lmax,kmax,lmax) + + thspB = thspB + sqg_static%thbB + thspT = thspT + sqg_static%thbT + + ! map into grid-point space space at the same resolution: + call sp_to_xy(thspB,thxyB,kmax,lmax,2*kmax,2*lmax) + call sp_to_xy(thspT,thxyT,kmax,lmax,2*kmax,2*lmax) + + deallocate(thspB) ; deallocate(thspT) + +endif + +! second add linear shear: +allocate(theta(2*kmax,2*lmax,2)) +do j = 1, 2*lmax + theta(:,j,1) = thxyB(:,j) - sqg_static%lam * real(j-1) * YL/real(2*lmax) + theta(:,j,2) = thxyT(:,j) - sqg_static%lam * real(j-1) * YL/real(2*lmax) +enddo + +! wrap model variables into DART state vector: +call sqg_to_dart(theta,x) + +deallocate(thxyB) ; deallocate(thxyT) +deallocate(theta) + +end subroutine init_conditions + +!======================================================================== + +subroutine adv_1step(x, current_time, target_time) +!------------------------------------------------- +! Does a time advance for sQG model with state vector as +! input and output. +! This interface advances from current_time to target_time +! and should be used with async = -2 +! see modifications in obs_model_mod.f90 + +real(r8), intent(inout) :: x(:) +type(time_type), intent(in) :: current_time +type(time_type), intent(in), optional :: target_time + +real(r8) :: cxB,cyB,cxT,cyT +integer :: j +integer :: itime, cdays, cseconds, tdays, tseconds +type(time_type) :: ctime + +real, allocatable, dimension(:,:,:) :: thxy +real, allocatable, dimension(:,:) :: thxyB, thxyT +real, allocatable, dimension(:,:) :: laplacian +real, allocatable, dimension(:,:) :: thxB, thxT, thyB, thyT +real, allocatable, dimension(:,:) :: uB, uT, vB, vT +real, allocatable, dimension(:,:) :: tthB, tthT + +complex, allocatable, dimension(:,:) :: thspB, thspT, thspB1, thspT1, thspB2, thspT2 +complex, allocatable, dimension(:,:) :: sB, sBold +complex, allocatable, dimension(:,:) :: tthspB, tthspT + +logical :: first + +! allocate necessary space up-front: +allocate(thxy(2*kmax,2*lmax,2)) +allocate(thxyB( 2*kmax,2*lmax)) ; allocate(thxyT( 2*kmax,2*lmax)) + +allocate(laplacian(mmax,nmax)) +allocate(thxB(mmax,nmax)) ; allocate(thxT(mmax,nmax)) +allocate(thyB(mmax,nmax)) ; allocate(thyT(mmax,nmax)) +allocate(uB( mmax,nmax)) ; allocate(uT( mmax,nmax)) +allocate(vB( mmax,nmax)) ; allocate(vT( mmax,nmax)) +allocate(tthB(mmax,nmax)) ; allocate(tthT(mmax,nmax)) + +allocate(thspB( 2*kmax,2*lmax)) ; allocate(thspT( 2*kmax,2*lmax)) +allocate(thspB1(2*kmax,2*lmax)) ; allocate(thspT1(2*kmax,2*lmax)) +allocate(thspB2(2*kmax,2*lmax)) ; allocate(thspT2(2*kmax,2*lmax)) + +allocate(sB(2*kmax,2*lmax)) ; allocate(sBold(2*kmax,2*lmax)) + +allocate(tthspB(mmax,nmax)) ; allocate(tthspT(mmax,nmax)) + +! unwrap DART state vector into model variables: +call dart_to_sqg(x, thxy) + +! first remove the linear shear: +do j = 1, 2*lmax + thxyB(:,j) = thxy(:,j,1) + sqg_static%lam * real(j-1) * YL/real(2*lmax) + thxyT(:,j) = thxy(:,j,2) + sqg_static%lam * real(j-1) * YL/real(2*lmax) +enddo + +! map into spectral space at the same resolution: +call xy_to_sp(cmplx(thxyB,0.0), thspB, 2*kmax,2*lmax, kmax, lmax) +call xy_to_sp(cmplx(thxyT,0.0), thspT, 2*kmax,2*lmax, kmax, lmax) + +! second remove the HW base-state: +if ( hw ) then + thspB = thspB - sqg_static%thbB + thspT = thspT - sqg_static%thbT +endif + +! initialize certain variables for first time-step +first = .true. +sB = 0.0 +thspB1 = 0.0; thspB2 = 0.0 +thspT1 = 0.0; thspT2 = 0.0 + +! advance from current_time to target_time: +itime = 1 +ctime = current_time +do while ( ctime < target_time ) + + ! save old stream-function for Ekman calculation: + sBold = sB + + ! invert theta for stream-function; compute gradients for advection: + call invert(thspB, thspT, thxB, thxT, thyB, thyT, vB, vT, uB, uT, & + sqg_static%thbB, sqg_static%thbT, sqg_static%thbyB, sqg_static%thbyT, & + sqg_static%ulinB, sqg_static%ulinT, & + first, sqg_static%bot, sqg_static%top, sqg_static%lam, & + sB, sBold, laplacian) + + ! option to compute potential enstrophy norm and growth rate: + if ( inorm ) call norm(thspB, thspT, itime) + + ! spectral advection: + if ( sqg_static%bot ) & + call advect(uB, vB, thxB, thyB, & + sqg_static%thbyB, sqg_static%hx, sqg_static%hy, sqg_static%ulinB, & + tthB, sqg_static%lam, laplacian) + if ( sqg_static%top ) & + call advect(uT + sqg_static%hu, vT + sqg_static%hv, thxT, thyT, & + sqg_static%thbyT, Rblank, Rblank, sqg_static%ulinT, & + tthT, sqg_static%lam, Rblank) + + ! compute Courant numbers and print to stdout if debugging: + if ( mod((itime-1),10) .eq. 0 ) then + cxB = maxval(abs(uB + sqg_static%ulinB)) * dt / (XL/real(2*kmax)) + cyB = maxval(abs(vB)) * dt / (YL/real(2*lmax)) + cxT = maxval(abs(uT + sqg_static%ulinT)) * dt / (XL/real(2*kmax)) + cyT = maxval(abs(vT)) * dt / (YL/real(2*lmax)) + if ( debug ) write(*,'(A23,F10.3,4F8.3))') 'time,cxB,cyB,cxT,cyT = ', & + real(itime-1)*dt,cxB,cyB,cxT,cyT + endif + + ! FFT back to spectral space: + if ( sqg_static%bot ) then + tthspB = cmplx(tthB,0.0) + call ft_2d(tthspB,mmax,nmax,-1) + endif + if ( sqg_static%top ) then + tthspT = cmplx(tthT,0.0) + call ft_2d(tthspT,mmax,nmax,-1) + endif + + ! advance one time-step with explicit (hyper-) diffusion: + if ( sqg_static%bot ) call tadv(thspB, tthspB, thspB1, thspB2, sqg_static%dco, first) + if ( sqg_static%top ) call tadv(thspT, tthspT, thspT1, thspT2, sqg_static%dco, first) + + ! zero out k=K, l=L modes on the bottom boundary: + thspB(kmax,:) = 0.0 ; thspB(lmax,:) = 0.0 + + itime = itime + 1 + ctime = ctime + time_step + + first = .false. + +enddo + +! first add the HW base-state: +if ( hw ) then + thspB = thspB + sqg_static%thbB + thspT = thspT + sqg_static%thbT +endif + +! map into grid-point space at the same resolution: +call sp_to_xy(thspB, thxyB, kmax, lmax, 2*kmax, 2*lmax) +call sp_to_xy(thspT, thxyT, kmax, lmax, 2*kmax, 2*lmax) + +! second add the linear shear: +do j = 1, 2*lmax + thxy(:,j,1) = thxyB(:,j) - sqg_static%lam * real(j-1) * YL/real(2*lmax) + thxy(:,j,2) = thxyT(:,j) - sqg_static%lam * real(j-1) * YL/real(2*lmax) +enddo + +! wrap model variables into DART state vector: +call sqg_to_dart(thxy, x) + +! deallocate space allocated up-front: +deallocate(thxy) +deallocate(thxyB ) ; deallocate(thxyT ) + +deallocate(laplacian) +deallocate(thxB) ; deallocate(thxT) +deallocate(thyB) ; deallocate(thyT) +deallocate(uB) ; deallocate(uT) +deallocate(vB) ; deallocate(vT) +deallocate(tthB) ; deallocate(tthT) + +deallocate(thspB ) ; deallocate(thspT ) +deallocate(thspB1) ; deallocate(thspT1) +deallocate(thspB2) ; deallocate(thspT2) + +deallocate(sB) ; deallocate(sBold) + +deallocate(tthspB) ; deallocate(tthspT) + +end subroutine adv_1step + +!======================================================================== + +function get_model_size() +!------------------------ +! Returns the size of the model as an integer. + +integer :: get_model_size + +get_model_size = model_size + +end function get_model_size + +!======================================================================== + +subroutine init_time(time) +!------------------------- +! For now, returns the initialization time as 0 + +type(time_type), intent(out) :: time + +! for now, just set to 0 +print*,'init_time' +time = set_time(0,0) + +end subroutine init_time + +!======================================================================== + +subroutine model_interpolate(x, location, itype, obs_val, istatus) +!----------------------------------------------------------------- +! Interpolates from state vector x to the location and returns obs_val. +! istatus = 0 suggests interpolation went ok, 1 means something went wrong. +! Argument itype specifies the type of field (for instance potential temperature in this model) + +real(r8), intent(in) :: x(:) +type(location_type), intent(in) :: location +integer, intent(in) :: itype +real(r8), intent(out) :: obs_val +integer, intent(out) :: istatus + +real(r8) :: lon, lat, lev, lon_lat_lev(3) +real(r8) :: bot_lon, top_lon, delta_lon, bot_lat, top_lat, delta_lat +real(r8) :: temp_lon, lon_fract, lat_fract, val(2,2), a(2) +integer :: lon_below, lon_above, lat_below, lat_above, level, i + +! Assume all interpolations okay for now +istatus = 0 + +lon_lat_lev = get_location(location) +lon = lon_lat_lev(1) +lat = lon_lat_lev(2) +lev = lon_lat_lev(3); level = int(lev) + +! Level is obvious for now, but make sure that it is within valid range +if ( (level < 1) .or. (level > 2) ) then + istatus = 1 + obs_val = MISSING_R8 + write(errstring,*)'level ',level,' must be 1 or 2' + call error_handler(E_ERR,'model_mod:model_interpolate', errstring, source, revision, revdate) +endif + +! Get globally defined lat / lon grid specs +bot_lon = sqg_static%lons(1) +top_lon = sqg_static%lons(2*kmax) +bot_lat = sqg_static%lats(1) +top_lat = sqg_static%lats(2*lmax) +delta_lon = sqg_static%lons(2) - sqg_static%lons(1) +delta_lat = sqg_static%lats(2) - sqg_static%lats(1) + +! Compute bracketing lon indices +if (lon >= bot_lon .and. lon <= top_lon ) then + lon_below = int((lon - bot_lon) / delta_lon) + 1 + lon_above = lon_below + 1 + lon_fract = (lon - ((lon_below - 1) * delta_lon + bot_lon)) / delta_lon +else + ! At wraparound point + lon_below = 2*kmax + lon_above = 1 + if(lon < bot_lon) then + temp_lon = lon + 360.0_r8 + else + temp_lon = lon + endif + lon_fract = (temp_lon - top_lon) / delta_lon +endif + +! Next, compute bracketing lat indices +if (lat >= bot_lat .and. lat <= top_lat) then + lat_below = int((lat - bot_lat) / delta_lat) + 1 + lat_above = lat_below + 1 + lat_fract = (lat - ((lat_below - 1) * delta_lat + bot_lat)) / delta_lat +else + ! Outside the channel, return with an error status + istatus = 1 + obs_val = MISSING_R8 + return +endif + +! Get values at the 4 surrounding points +val(1,1) = get_val(x, lon_below, lat_below, level) +val(1,2) = get_val(x, lon_below, lat_above, level) +val(2,1) = get_val(x, lon_above, lat_below, level) +val(2,2) = get_val(x, lon_above, lat_above, level) + +! Do the weighted average for interpolation +if ( debug ) write(*,*) 'fracts ', lon_fract, lat_fract +do i = 1, 2 + a(i) = lon_fract * val(2, i) + (1.0 - lon_fract) * val(1, i) +end do + +obs_val = lat_fract * a(2) + (1.0 - lat_fract) * a(1) + +end subroutine model_interpolate + +!======================================================================== + +function get_val(x, lon_index, lat_index, level) +!----------------------------------------------- +! Given the state vector and location, returns the value at that location + +real(r8), intent(in) :: x(:) +integer, intent(in) :: lon_index, lat_index, level +real(r8) :: get_val + +integer :: indx + +indx = (level-1)*(2*lmax)*(2*kmax) + (lat_index-1)*(2*kmax) + lon_index + +!! should not be possible now; but this error check can be commented back in. +!! (it is out for performance reasons, but if you get any strange values, this +!! is a good first check to re-enable.) +!if (indx < 1 .or. indx > size(x)) then +! write(errstring,*)'index ',indx,' not between 1 and ', size(x), ' (should not be possible)' +! call error_handler(E_ERR,'model_mod:get_val', errstring, source, revision, revdate) +!endif + +get_val = x(indx) + +end function get_val + +!======================================================================== + +function get_model_time_step() +!----------------------------- +! Returns the time step of the model + +type(time_type) :: get_model_time_step + +get_model_time_step = time_step + +end function get_model_time_step + +!======================================================================== + +subroutine get_state_meta_data(index_in, location, var_type) +!----------------------------------------------------------- +! Given an integer index into the state vector structure, returns the +! associated location. + +integer, intent(in) :: index_in +type(location_type), intent(out) :: location +integer, intent(out), optional :: var_type + +integer :: lev_index, lat_index, lon_index +real(r8) :: lon, lat, lev +integer :: location_index + +! avoid out-of-range queries +if ( index_in > model_size ) then + write(errstring,*)'index_in ',index_in,' must be between 1 and ', model_size + call error_handler(E_ERR,'model_mod:get_state_meta_data', errstring, source, revision, revdate) +endif + +lev_index = (index_in-1) / ((2*lmax)*(2*kmax)) + 1 +lat_index = ((index_in-1) - ((lev_index-1)*(2*lmax)*(2*kmax))) / (2*kmax) + 1 +lon_index = (index_in-1) - ((lev_index-1)*(2*lmax)*(2*kmax)) - ((lat_index-1)*(2*kmax)) + 1 + +lev = sqg_static%levs(lev_index) +lat = sqg_static%lats(lat_index) +lon = sqg_static%lons(lon_index) + +! With the threed_sphere location module ... you specify that the +! vertical coordinate is a 'level' by 'which_vert' == 1 +location = set_location(lon, lat, lev, 1) + +! Alternately, use state_loc that is defined in static_init_model() +!location = state_loc(index_in) + +if (present(var_type)) var_type = KIND_POTENTIAL_TEMPERATURE + +end subroutine get_state_meta_data + +!======================================================================== + +subroutine end_model() +!--------------------- +! Does any shutdown and clean-up needed for model. + +! good practice ... deallocate stuff from static_init_model +deallocate(sqg_static%lons) ; deallocate(sqg_static%lats) ; deallocate(sqg_static%levs) + +deallocate(sqg_static%thbB ) ; deallocate(sqg_static%thbT ) +deallocate(sqg_static%thbyB) ; deallocate(sqg_static%thbyT) +deallocate(sqg_static%ulinB) ; deallocate(sqg_static%ulinT) + +deallocate(sqg_static%hx) ; deallocate(sqg_static%hy) +deallocate(sqg_static%hu) ; deallocate(sqg_static%hv) + +deallocate(state_loc) + +end subroutine end_model + +!======================================================================== + +function nc_write_model_atts( ncFileID ) result (ierr) +!----------------------------------------------------- +! Writes the model-specific attributes to a netCDF file. + +use typeSizes +use netcdf + +integer, intent(in) :: ncFileID ! netCDF file identifier +integer :: ierr ! return value of function + +integer :: nDimensions, nVariables, nAttributes, unlimitedDimID + +integer :: latDimID, lonDimID, levDimID, StateVarDimID, MemberDimID, TimeDimID +integer :: latVarID, lonVarID, levVarID, StateVarVarID, StateVarID + +character(len=8) :: crdate ! needed by F90 DATE_AND_TIME intrinsic +character(len=10) :: crtime ! needed by F90 DATE_AND_TIME intrinsic +character(len=5) :: crzone ! needed by F90 DATE_AND_TIME intrinsic +integer, dimension(8) :: values ! needed by F90 DATE_AND_TIME intrinsic +character(len=NF90_MAX_NAME) :: str1 +character(len=NF90_MAX_NAME) :: filename + +integer :: i + +ierr = -1 ! assume things go poorly + +!-------------------------------------------------------------------- +! we only have a netcdf handle here so we do not know the filename +! or the fortran unit number. but construct a string with at least +! the netcdf handle, so in case of error we can trace back to see @@ Diff output truncated at 40000 characters. @@
    Contact: nancy collins
    Contact: Tim Hoar
    Revision: $Revision$
    Source: $URL$
    Change Date: $Date$