htcp

Properties of water suspended in clouds
git clone git://git.meso-star.fr/htcp.git
Log | Files | Refs | README | LICENSE

commit 75e5bed179c30c0d81116af22df6059a509de2b5
parent 2f1ad5f9b325a653562ba43401b168b50acb2d4a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 13 Jul 2018 17:00:50 +0200

Add the loading the PABST and T HTCP field in the HTCP library

Diffstat:
Msrc/htcp.c | 10++++++++++
Msrc/htcp.h | 20+++++++++++++++++++-
Msrc/test_htcp_load.c | 14++++++++++++++
3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/src/htcp.c b/src/htcp.c @@ -40,8 +40,12 @@ struct htcp { double* RCT; /* Mapped memory */ double* RVT; /* Mapped memory */ + double* PABST; /* Mapped memory */ + double* T; /* Mapped memory */ size_t RCT_length; /* In bytes */ size_t RVT_length; /* In bytes */ + size_t PABST_length; /* In bytes */ + size_t T_length; /* In bytes */ size_t pagesize_os; /* Page size of the os */ int verbose; /* Verbosity level */ @@ -94,6 +98,8 @@ reset_htcp(struct htcp* htcp) darray_double_clear(&htcp->vxsz_z); if(htcp->RCT) munmap(htcp->RCT, htcp->RCT_length); if(htcp->RVT) munmap(htcp->RVT, htcp->RVT_length); + if(htcp->PABST) munmap(htcp->PABST, htcp->PABST_length); + if(htcp->T) munmap(htcp->T, htcp->T_length); htcp->RCT = NULL; htcp->RVT = NULL; htcp->RCT_length = 0; @@ -189,6 +195,8 @@ load_stream(struct htcp* htcp, FILE* stream, const char* stream_name) } (void)0 MMAP(RVT); offset += (off_t)map_len; MMAP(RCT); offset += (off_t)map_len; + MMAP(PABST); offset += (off_t)map_len; + MMAP(T); offset += (off_t)map_len; #undef MMAP CHK(fseek(stream, offset, SEEK_CUR) != -1); @@ -330,6 +338,8 @@ htcp_get_desc(const struct htcp* htcp, struct htcp_desc* desc) desc->vxsz_z = darray_double_cdata_get(&htcp->vxsz_z); desc->RCT = htcp->RCT; desc->RVT = htcp->RVT; + desc->PABST = htcp->PABST; + desc->T = htcp->T; return RES_OK; } diff --git a/src/htcp.h b/src/htcp.h @@ -59,8 +59,10 @@ struct htcp_desc { const double* RCT; const double* RVT; + const double* PABST; /* Pressure */ + const double* T; /* Temperature */ }; -#define HTCP_DESC_NULL__ {0,-1,{0,0,0},0,{-1,-1,-1},-1,-1,NULL,NULL,NULL} +#define HTCP_DESC_NULL__ {0,-1,{0,0,0},0,{-1,-1,-1},-1,-1,NULL,NULL,NULL,NULL,NULL} static const struct htcp_desc HTCP_DESC_NULL = HTCP_DESC_NULL__; BEGIN_DECLS @@ -134,6 +136,22 @@ htcp_desc_RVT_at return htcp_dblgrid4D_at__(desc->RVT, desc, x, y, z, t); } +static FINLINE double +htcp_desc_PABST_at + (const struct htcp_desc* desc, + size_t x, size_t y, size_t z, size_t t) +{ + return htcp_dblgrid4D_at__(desc->PABST, desc, x, y, z, t); +} + +static FINLINE double +htcp_desc_T_at + (const struct htcp_desc* desc, + size_t x, size_t y, size_t z, size_t t) +{ + return htcp_dblgrid4D_at__(desc->T, desc, x, y, z, t); +} + END_DECLS #endif /* HTCP_H */ diff --git a/src/test_htcp_load.c b/src/test_htcp_load.c @@ -65,6 +65,18 @@ main(int argc, char** argv) } fseek(stream, ALIGN_SIZE(ftell(stream), pagesize), SEEK_SET); /* padding */ + FOR_EACH(i, 0, i32[0]*i32[1]*i32[2]*i32[3]) { /* PABST */ + dbl[0] =-(double)i; + CHK(fwrite(dbl, sizeof(dbl[0]), 1, stream) == 1); + } + fseek(stream, ALIGN_SIZE(ftell(stream), pagesize), SEEK_SET); /* padding */ + + FOR_EACH(i, 0, i32[0]*i32[1]*i32[2]*i32[3]) { /* T */ + dbl[0] =-(double)i; + CHK(fwrite(dbl, sizeof(dbl[0]), 1, stream) == 1); + } + fseek(stream, ALIGN_SIZE(ftell(stream), pagesize), SEEK_SET); /* padding */ + rewind(stream); CHK(htcp_create(NULL, &mem_default_allocator, 1, &htcp) == RES_OK); @@ -110,6 +122,8 @@ main(int argc, char** argv) FOR_EACH(x, 0, desc.spatial_definition[0]) { CHK(htcp_desc_RVT_at(&desc, x, y, z, t) == (double)i); CHK(htcp_desc_RCT_at(&desc, x, y, z, t) ==-(double)i); + CHK(htcp_desc_PABST_at(&desc, x, y, z, t) ==-(double)i); + CHK(htcp_desc_T_at(&desc, x, y, z, t) ==-(double)i); ++i; }}}} CHK(htcp_ref_put(htcp) == RES_OK);