Home > fvcom_prepro > read_fabm_variables.m

read_fabm_variables

PURPOSE ^

For a given configuration, read the ersem variables required to run the

SYNOPSIS ^

function [varlist] = read_fabm_variables(conf)

DESCRIPTION ^

 For a given configuration, read the ersem variables required to run the
 model

 [varlist] = get_fabm_variables(conf)

 DESCRIPTION:
   The conf struct contains the parameters needed to locate the restart
   file. We only need the variable names...

 INPUT:
   conf - struct. With fields:
       * restart_file - FVCOM restart file with FABM variables (i.e. a donor file).
 OUTPUT:
   varlist - cell array of ERSEM variables.

 EXAMPLE USAGE:
   [varlist] = get_fabm_variables(conf);

 Author(s):
   Ricardo torres (Plymouth Marine Laboratory)

 Revision history:
   2017-03-10 - First version 

==========================================================================
 hard coding these is a bad habit!! These should be identical to the ones
 in get_POLCOMS_ERSEM.m
 conf.casename = 'aqua_v14';
 conf.base_dir = '/users/modellers/rito';
 conf.project_dir = fullfile(conf.base_dir, '/Models/git/fvcom/rosa-implementation/');
 conf.restart_file = fullfile(conf.project_dir, 'matlab/restarts/', ...
     sprintf('%s_ersem_restart_donor.nc', conf.casename));

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [varlist] = read_fabm_variables(conf)
0002 % For a given configuration, read the ersem variables required to run the
0003 % model
0004 %
0005 % [varlist] = get_fabm_variables(conf)
0006 %
0007 % DESCRIPTION:
0008 %   The conf struct contains the parameters needed to locate the restart
0009 %   file. We only need the variable names...
0010 %
0011 % INPUT:
0012 %   conf - struct. With fields:
0013 %       * restart_file - FVCOM restart file with FABM variables (i.e. a donor file).
0014 % OUTPUT:
0015 %   varlist - cell array of ERSEM variables.
0016 %
0017 % EXAMPLE USAGE:
0018 %   [varlist] = get_fabm_variables(conf);
0019 %
0020 % Author(s):
0021 %   Ricardo torres (Plymouth Marine Laboratory)
0022 %
0023 % Revision history:
0024 %   2017-03-10 - First version
0025 %
0026 %==========================================================================
0027 % hard coding these is a bad habit!! These should be identical to the ones
0028 % in get_POLCOMS_ERSEM.m
0029 % conf.casename = 'aqua_v14';
0030 % conf.base_dir = '/users/modellers/rito';
0031 % conf.project_dir = fullfile(conf.base_dir, '/Models/git/fvcom/rosa-implementation/');
0032 % conf.restart_file = fullfile(conf.project_dir, 'matlab/restarts/', ...
0033 %     sprintf('%s_ersem_restart_donor.nc', conf.casename));
0034 
0035 
0036 subname = 'read_fabm_variables';
0037 global ftbverbose
0038 if ftbverbose
0039     fprintf('\nbegin : %s\n', subname)
0040 end
0041 
0042 % check file exist
0043 %
0044 
0045 if exist(conf.restart_file,'file')
0046 % read ersem variables in donor restart file
0047 info_donor=ncinfo(conf.restart_file);
0048 else
0049     warning('File %s not found. Returning', conf.restart_file)
0050     return
0051 end
0052 % Generally the last fvcom variable although this could change with a
0053 % different configuration of output variables. Better check on a case by case
0054 % There is no FABM reference in the variable attributes to possibly do it differently
0055 last_fvcom = 'wet_cells_prev_ext';
0056 idx = find(strcmpi({info_donor.Variables.Name},last_fvcom));
0057 ii=1;varlist={};
0058 for ff=idx+1:length(info_donor.Variables)
0059     % brute force search...
0060     res = strfind(info_donor.Variables(ff).Name,['_']);
0061     if ~isempty(res)
0062         % variable seems to have the construct of FABM ...
0063         % check is not a benthic variable
0064         if (length(info_donor.Variables(ff).Dimensions)==3)
0065             varlist(ii)={info_donor.Variables(ff).Name};
0066             ii = ii+1;
0067             
0068         end
0069     end
0070 end
0071 
0072 return

Generated on Wed 20-Feb-2019 16:06:01 by m2html © 2005