#include <stdio.h>#include <string.h>#include <netcdf.h>#include "nco_netcdf.h"#include "nco.h"#include "nco_att_utl.h"#include "nco_mmr.h"Include dependency graph for nco_cnv_arm.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| bool | arm_inq (const int nc_id) |
| double | arm_time_mk (const int nc_id, const double time_offset) |
| void | nco_arm_time_install (const int nc_id, const nco_int base_time_srt) |
| nco_int | arm_base_time_get (const int nc_id) |
|
|
Definition at line 162 of file nco_cnv_arm.c. References var_sct_tag::nc_id, NC_INT, nco_get_var1(), and nco_inq_varid(). Referenced by main(). 00163 { 00164 /* NB: arm_base_time_get() with same nc_id contains OpenMP critical region */ 00165 /* Purpose: Get base_time variable from ARM file */ 00166 int base_time_id; 00167 00168 nco_int base_time; 00169 00170 (void)nco_inq_varid(nc_id,"base_time",&base_time_id); 00171 00172 /* Block is critical/thread-safe for identical/distinct in_id's */ 00173 { /* begin potential OpenMP critical */ 00174 (void)nco_get_var1(nc_id,base_time_id,0L,&base_time,NC_INT); 00175 } /* end potential OpenMP critical */ 00176 00177 return base_time; 00178 } /* end arm_base_time_get */
|
|
|
Definition at line 13 of file nco_cnv_arm.c. References dbg_lvl_get(), False, var_sct_tag::nc_id, NC_NOERR, nco_bool, nco_inq_dimid_flg(), nco_inq_varid_flg(), prg_nm_get(), and True. Referenced by main(). 00014 { 00015 /* Purpose: Check whether file adheres to ARM time format */ 00016 nco_bool CNV_ARM; 00017 00018 const char time_sng[]="time"; /* CEWI */ 00019 const char base_time_sng[]="base_time"; /* CEWI */ 00020 const char time_offset_sng[]="time_offset"; /* CEWI */ 00021 00022 int time_dmn_id; 00023 int base_time_id; 00024 int time_offset_id; 00025 int rcd=NC_NOERR; /* [rcd] Return code */ 00026 00027 /* Look for ARM file signature */ 00028 rcd+=nco_inq_dimid_flg(nc_id,time_sng,&time_dmn_id); 00029 rcd+=nco_inq_varid_flg(nc_id,base_time_sng,&base_time_id); 00030 rcd+=nco_inq_varid_flg(nc_id,time_offset_sng,&time_offset_id); 00031 00032 /* All three IDs must be valid to handle ARM format */ 00033 if(rcd != NC_NOERR){ 00034 CNV_ARM=False; 00035 }else{ 00036 if(dbg_lvl_get() > 0) (void)fprintf(stderr,"%s: CONVENTION File convention is DOE ARM\n",prg_nm_get()); 00037 CNV_ARM=True; 00038 } /* end else */ 00039 00040 return CNV_ARM; 00041 } /* end arm_inq */
|
|
||||||||||||
|
Definition at line 45 of file nco_cnv_arm.c. References var_sct_tag::nc_id, NC_INT, NC_NOERR, nco_get_var1(), nco_inq_varid_flg(), and prg_nm_get(). 00047 { 00048 /* NB: arm_time_mk() with same nc_id contains OpenMP critical region */ 00049 /* Purpose: Return time corresponding to current time offset */ 00050 double arm_time; 00051 00052 int base_time_id; 00053 int rcd=NC_NOERR; /* [rcd] Return code */ 00054 00055 nco_int base_time; 00056 00057 /* Find base_time variable (NC_INT: base UNIX time of file) */ 00058 rcd=nco_inq_varid_flg(nc_id,"base_time",&base_time_id); 00059 if(rcd != NC_NOERR){ 00060 (void)fprintf(stderr,"%s: WARNING ARM file does not have variable \"base_time\", exiting arm_time_mk()...\n",prg_nm_get()); 00061 return -1; 00062 } /* end if */ 00063 00064 { /* begin potential OpenMP critical */ 00065 /* Block is critical/thread-safe for identical/distinct in_id's */ 00066 (void)nco_get_var1(nc_id,base_time_id,0L,&base_time,NC_INT); 00067 } /* end potential OpenMP critical */ 00068 arm_time=base_time+time_offset; 00069 00070 return arm_time; 00071 } /* end arm_time_mk() */
|
|
||||||||||||
|
Definition at line 75 of file nco_cnv_arm.c. References var_sct_tag::cnt, NC_CHAR, NC_DOUBLE, var_sct_tag::nc_id, NC_NOERR, nco_def_var(), nco_enddef(), nco_free(), nco_get_vara(), nco_hst_att_cat(), nco_inq_dimid_flg(), nco_inq_dimlen(), nco_inq_varid_flg(), nco_malloc(), nco_put_att(), nco_put_vara(), nco_redef(), nco_sync(), nco_typ_lng(), prg_nm_get(), and var_sct_tag::srt. Referenced by main(). 00077 { 00078 /* NB: arm_time_install() contains OpenMP critical region */ 00079 /* Purpose: Add time variable to concatenated ARM files */ 00080 00081 const char att_long_name[]="UNIX time"; 00082 const char att_units[]="seconds since 1970/01/01 00:00:00.00"; 00083 const char long_name_sng[]="long_name"; /* CEWI */ 00084 const char time_sng[]="time"; /* CEWI */ 00085 const char units_sng[]="units"; /* CEWI */ 00086 00087 double *time_offset; 00088 00089 int rcd=NC_NOERR; /* [rcd] Return code */ 00090 int time_id; 00091 int time_dmn_id; 00092 int time_offset_id; 00093 00094 long idx; 00095 long srt=0L; 00096 long cnt; 00097 00098 /* Synchronize output file */ 00099 (void)nco_sync(nc_id); 00100 00101 /* Find time_offset variable */ 00102 rcd=nco_inq_varid_flg(nc_id,"time_offset",&time_offset_id); 00103 if(rcd != NC_NOERR){ 00104 (void)fprintf(stderr,"%s: WARNING ARM file does not have variable \"time_offset\", exiting nco_arm_time_install()...\n",prg_nm_get()); 00105 return; 00106 } /* endif */ 00107 00108 /* See if time variable already exists */ 00109 rcd=nco_inq_varid_flg(nc_id,time_sng,&time_id); 00110 if(rcd == NC_NOERR){ 00111 (void)fprintf(stderr,"%s: WARNING ARM file already has variable \"time\"\n",prg_nm_get()); 00112 return; 00113 } /* endif */ 00114 00115 /* See if time dimension exists */ 00116 rcd=nco_inq_dimid_flg(nc_id,time_sng,&time_dmn_id); 00117 if(rcd != NC_NOERR){ 00118 (void)fprintf(stderr,"%s: WARNING ARM file does not have dimension \"time\"\n",prg_nm_get()); 00119 return; 00120 } /* endif */ 00121 /* Get dimension size */ 00122 (void)nco_inq_dimlen(nc_id,time_dmn_id,&cnt); 00123 00124 /* If the time coordinate does not already exist, create it */ 00125 time_offset=(double *)nco_malloc(cnt*nco_typ_lng(NC_DOUBLE)); 00126 00127 { /* begin potential OpenMP critical */ 00128 /* Block is critical/thread-safe for identical/distinct in_id's */ 00129 (void)nco_get_vara(nc_id,time_offset_id,&srt,&cnt,(void *)time_offset,NC_DOUBLE); 00130 } /* end potential OpenMP critical */ 00131 00132 for(idx=0L;idx<cnt;idx++) time_offset[idx]+=base_time_srt; 00133 00134 /* File must be in define mode */ 00135 (void)nco_redef(nc_id); 00136 (void)nco_def_var(nc_id,time_sng,NC_DOUBLE,1,&time_dmn_id,&time_id); 00137 00138 /* Add attributes for time variable */ 00139 (void)nco_put_att(nc_id,time_id,units_sng,NC_CHAR,(long)(strlen(att_units)+1UL),(const void *)att_units); 00140 (void)nco_put_att(nc_id,time_id,long_name_sng,NC_CHAR,(long)(strlen(att_long_name)+1UL),(const void *)att_long_name); 00141 00142 /* Catenate time-stamped reminder onto "history" global attribute */ 00143 (void)nco_hst_att_cat(nc_id,"ncrcat added variable time=base_time+time_offset"); 00144 00145 /* Take file out of define mode */ 00146 (void)nco_enddef(nc_id); 00147 00148 /* Block is always critical */ 00149 { /* begin OpenMP critical */ 00150 /* Write time variable */ 00151 (void)nco_put_vara(nc_id,time_id,&srt,&cnt,(void *)time_offset,NC_DOUBLE); 00152 } /* end OpenMP critical */ 00153 00154 /* Free time_offset buffer */ 00155 time_offset=(double *)nco_free(time_offset); 00156 00157 return; /* 20050109: fxm added return to void function to squelch erroneous gcc-3.4.2 warning */ 00158 } /* end nco_arm_time_install */
|
1.4.4